Sablotron XSLT , PHP, Apache on Windows (and a basic XSLT tutorial)

Written by Shanx May 27th, 2003

Sablotron XSLT , PHP, Apache on Windows (and a basic XSLT tutorial)

Continue reading →
Close

It is actually quite simple to get it working, but not adequately documented on the PHP website. Get straightforward, bullet point instructions here (installs PHP as a module which is in fact faster than running it as CGI).

It is actually quite simple to get it working, but not adequately documented on the PHP website. Get straightforward, bullet point instructions here (installs PHP as a module which is in fact faster than running it as CGI).

  1. Get the latest PHP package from http://qa.php.net/ and unzip it. It will automatically create a folder named PHP_version. (P.S. Novice users may want to skip this entirely and download PHP, MYSQL etc bundled as
    XAMPP from Apachefriends.org.
    )
  2. Please follow the instructions in the README to install
    Apache as a module (faster than running as CGI). This should include –

    1. Copying the latest PHP files into your C:\PHP or wherever you have your PHP installed,
    2. Putting your PHP.INI file in the right place, mine is in C:\WINDOWS (you must have only one valid INI file),
    3. Copying the php4ts.dll file from your downloaded PHP_version folder into C:\WINDOWS\SYSTEM32
  3. Copy all the *.dll files from your downloaded
    PHP_version\DLL folder into the C:\WINDOWS\SYSTEM32.
    This will include the latest expat.dll and the
    sablot.dll.
  4. Copy the php_xslt.dll from your downloaded PHP_version\EXTENSIONS folder into the C:\WINDOWS\SYSTEM32.
  5. Now, open your PHP.INI and uncomment the
    php_xslt.dll extension.


    1. # Remove the semi-colon ";" at the beginning
      # of the line to uncomment the PHP_XSLT extension

      OLD LINE –> ;extension=php_xslt.dll

      NEW LINE –> extension=php_xslt.dll
  6. Just for reference, my HTTPD.CONF file for Apache
    has the PHP module working as follows:

    1. # P.S. The LoadModule should be php4apache2.dll
      if you use Apache 2

      ScriptAlias /php/ “c:/php/”
      LoadModule php4_module c:/php/sapi/php4apache.dll

      AddType application/x-httpd-php .php
  7. Restart Apache, and hopefully time to say Bingo! If you have problems, please let
    me know
    .


Testing your PHP XSLT installation:

Following is a zip file containing some examples for you to
test out your XSLT installation. Unzip it into your htdocs
folder, it will create a subfolder called xsltest.
Please read the README.TXT file inside this ZIP file for more.

Important notes to make sure XSLT works with PHP module of Apache:

  1. If running PHP as a module gives you problems, make sure you copy the
    php4ts.dll file from your downloaded PHP_version
    folder into C:\WINDOWS\SYSTEM32. This is
    most often the cause of errors.
  2. Make sure you don’t have many copies of the same DLLs lurking around
    in various folders. This is often the problem. Specifically, for instance,
    the same DLLs should not exist in C:\WINDOWS\SYSTEM and the C:\WINDOWS\SYSTEM32
    folders.
  3. If you are using really ancient versions of PHP (i.e., version less
    than 4.1.xx) then this page
    may be useful
    to you as well.
If you are reading this, you may also want to check out this Zend Tutorial about PECL extension for XSLT processing.

Posted in Miscellaneous

137 Comments

Tagged with

137 Comments

  1. Sina says:

    Has anyone generated DocBook Website output using this method?

  2. Rinkeyreggae says:

    Concerning placing dlls in your system32 folder.

    I had a problem with apache not finding my modules while they were at the exact location as specified. Problem solved as I put php5ts.dll in the system32 folder. Turns out the other dlls need this one and it needs to be in the system path. I Suppose if you put the dir where php5ts.dll originally is in the path it will also work.

  3. foxvin says:

    Hi thanks for giving the instruction on how to configure the xslt. I just have 1 problem, my php 4 is ok and working properly. But I also what to use xslt extension under php 5 but when I follow the same instruction it did not work on php 5 because the php_xslt.dll i have is i think design for php 4 only can u help me find php_xslt.dll for php 5.

    thanks

  4. philip ray says:

    Thanks you for the procedure to overcome my problem, but still i need some tips to generate a powerful index. because i use xslt and xml for this document.

  5. edi says:

    If it still doesn’t work and you did what this tutorial says, try copying expat.dll, iconv.dll and sablot.dll to your system folder (c:\window\system32 on my pc).
    I found these dlls in the ‘dlls’ folder of my php distribution.

  6. mogyi says:

    When you begin desperately copying files into C:\WINDOWS\system32 .. and still not seeing any results try to begin with iconv.dll !
    Normally you should NOT copy php4ts.dll, that should reside in the default php installation folder.

  7. noob says:

    Hi. Getting a problem when trying to run Apache 1.3.. I got win 98 as an OS. The error message in the Prompt is like this:

    [warn] No such file or directory: exec> may not be safe

    Under that it says:

    Apache/1.3.33 PHP/4.3.10 running…

    It seems ok, but then when I try to make a simple PHP test and starting in the browser with ‘http://localhost/test.php’, then the WHOLE code shows up, NOT only the ‘echo’ in the PHP code, as it should be. so that is the problem for me.. you know what the problem could be?

  8. Paulo Basto says:

    how to enable sablotron XSLT on your TSW server
    You don’t need to download anything. TSW has everything you need, it just needs a little tweaking ;)

    I copied essential files from the php folder to windows\system32

    sablot.dll
    expat.dll
    php4ts.dll
    php_xslt.dll

    checked first if php was being loaded as a module on the apache.conf there should be an entry like this:

    LoadModule php4_module

    checked also on \\localhost\php.info to see if everything was allright. There you should see this line:

    PHP Version 4.3.8

    Configuration File (php.ini) Path C:/TSW/Apache2/conf/php.ini

    ———————————–

    Now that you know where php.ini resides, go and remove this comments in it:

    OLD LINE –> ;extension=php_xslt.dll
    NEW LINE –> extension=php_xslt.dll

    did the same for php_iconv.dll (though i don’t think its mandatory)

    -Under PATHS AND DIRECTORIES, ADDED this path lines:

    include_path = “.;C:\TSW\Apache2\php\”
    include_path = “.;C:\WINDOWS\system32\”

    Though i dont think it was necessary (heck! I dont even know if its really necessary to copy the .dll files to sys32!!).
    Its working now, and thats what matters… for now :)

    ———————————————–

    Then finally my last and decisive step was editing php_handler.conf located in C:\TSW\Apache2\conf\mods, uncommenting the following:

    PHPINIDir conf/php.ini

    LoadFile dll/sablot.dll
    LoadFile dll/libintl-1.dll
    LoadFile dll/gds32.dll
    LoadFile dll/libmhash.dll
    LoadFile php/pdflib.dll

    AddType application/x-httpd-php .php .php3 .info
    AddType application/x-httpd-php-source .phps

    ——

    In the end your php.ini output should have this extra fields:

    xml
    XML Support active
    XML Namespace Support active
    EXPAT Version 1.95.6

    xslt
    XSLT support enabled
    Backend Sablotron
    Sablotron Version 1.0

    Ready to rock!?? I am… :)

  9. Peter Ruzicka says:

    Thank You!
    This article is very helpfull.

  10. marek says:

    my question is if it is posible to run xslt on XAMPP and how to do that?
    Thank You.

  11. jarra says:

    thank you.
    it helped me a lot!
    cheers

  12. Dave says:

    I was just wondering, as I’m new to XSLT, can a person use it without an xsl stylesheet? – I have an existing stylesheet I’d like to use – a css, is there either a way to refference that instead, or to convert my css to xsl?

  13. Moe says:

    Syntax error on line 519 of C:/Program Files/Apache Group/Apache2/conf/httpd
    f:
    Cannot load C:/PHP/sapi/php4apache.dll into server: The specified module cou
    ot be found.
    Note the errors or messages above, and press the key to exit. 17…

  14. booboop says:

    I’ve neen trying to do everything according to
    the instructions above->Windows xp, Apache2,
    php 4.3.10.But XSLT had not been added to the php info page and the code for running a test didn’t work.
    Also according to some instructions in the php
    homepage I’ve moved php.ini to the php folder
    (c:/php/) and changed the extension_dir to
    c:/php/extensions/ (removing the dll’s from the SYSTEM32 folder)
    and moved the’;’ from extension=php_xslt.dll
    things are not working !
    Any suggestion ?

  15. Leonardo Chinchilla says:

    Hello,

    I does, every step, but I have the following error when start the apache server: Unable to load dynamic library ‘./php_sxl.dll”

    Regards

  16. JP says:

    Hi there

    I have configured PHP Version 5.0.4 on windows. Everything seems to work fine except
    $xh = xslt_create();

    Fatal error: Call to undefined function xslt_create().

    In your tutorial you have suggested
    “open your PHP.INI and uncomment the php_xslt.dll extension”

    But i dont have any such line, instead i have php_xsl.dll, which i uncommented but no success.

    Kindly suggest for this new verion of PHP.

    Regards

  17. jkue says:

    JP, SimpleXML is builtin and has (my opinion) easier implementation. Example below.

    — XML FILE: test.xml —
    <?xml version=”1.0″?>
    <human>
    <person>
    <firstname>Henry</firstname>
    <lastname>Connor</lastname>
    <email>hencor@youknow.com</email>
    </person>

    — PHP CODE —
    <?php>
    $human = simplexml_load_file(‘./test.xml’);
    foreach($human->person as $person) {
    echo ‘Firstname:’.$person->firstname;
    echo ‘Lastname:’.$person->lastname;
    echo ‘Email:’.$person->email;
    }
    ?>

    The rest is up to your imagination, hope this helps some.

  18. sniptools says:

    Jkue, thanks for the contribution, I believe your code was caught up in our correction facility. Please mail me the code at shanx at sniptools dot com and I’ll put it up here. Cheers!

  19. jkue says:

    Was sent today Shanx.

  20. Aristidis says:

    hello,
    When I am writting in httpd.conf the load module and restart apache2 server it appears a warning
    can not load c:/php/sapi/php4apache2.dll to the server
    regards

  21. burhan says:

    i m using php 5 . there is no xslt.dll written in php.ini. and your code error is
    Fatal error: Call to undefined function xslt_create() in c:\webs\test\xsltest\complex.php on line 8
    reply me plz

  22. PAblo says:

    There is no XSLT Support in PHP5, you have to use DOM instead, or downgrade to PHP4

  23. sniptools says:

    Hi Pablo, that’s not entirely accurate. PHP5 does have XSLT support although that’s been moved to PECL. There’s more info here: http://www.php.net/manual/en/ref.xslt.php

    Quote:
    Note: This extension has been moved to the PECL repository and is no longer bundled with PHP as of PHP 5.0.0. If you need xslt support with PHP 5 you can use the XSL extension.

    That said, I agree with your general idea, using DomDocument is a lot faster on most systems.

  24. Lee says:

    I’ve installed Apache2, PHP and MySQL under WinXP. I’m running an XSLT transformation from a small PHP file and PHP won’t resolve the urls of the files involved correctly. I put “xml_file.xml” and “xsl_file.xsl” in the script for XSLT to work with, and the script tries to resolve the file URLs as c:\PHP\xml_file.xml, etc. even though the html pages correctly resolve partial urls to the htdocs dir under Apache. I think this is the problem with the XSL transformation coming up with the generic “invalid token”. Am I missing something in the PHP.ini that’s causing the error in resolving the urls? Any ideas would be very helpful!

  25. Lee says:

    Forget what I just posted. After downloading your sample files and finding that they worked just fine. My problem was the xslt_set_base command (I didn’t have one). Once I tore apart your file, I see that the file:// url had to be used instead of pointing at my server http:// url.

  26. jirka says:

    hi, thanks a lot, after 2 days of searching this was the only ! working method :-)

  27. anu says:

    every thing works fine.except tht when i run my apache4 ..,it says unable to load the module.the exact error is….
    cannot load c:/php/php4apache2.dllinto server…the specified module could not be found

  28. sniptools says:

    Anu, I guess you meant PHP4, not Apache4. That’s the most common error people see when they have not followed install instructions that come with PHP.

  29. tom says:

    from http://qa.php.net/ and unzip
    doesn’t seem to have any versions for windows -
    I’ve found many versions of how to get xslt to work with windows – all slightly different but
    doesn’t seem to work with PHP 5+
    using sablot expat and placing the appropriate .dll files in the right places, making config changes see straight forward but all the doc i reads slightly contradicts and seems to be a year or 2 old.

  30. sparky__ says:

    I’m using PHP Version 4.4.2 with IIS using ISAPI.

    I got it all working in my windows xp machine but i copy it to my w2003 machine(s) , the xslt wont appear at all in the phpinfo!!!
    xslt:
    XSLT support enabled
    Backend Sablotron
    Sablotron Version 1.0

    Also for some reason the Configuration File (php.ini) Path is C:\WINDOWS\php.ini inststead of C:\WINDOWS\system32\php.ini as it was in xp ?!?!

    It’s reading the ini (now i put it c:\windows instead) because i’ve changed the highlight.bg as a test.. whenever i change it in the ini and restart iis this updates but the xslt just wont include.. im not sure why as all the settings are the same. [this was after failing to get it to work in either with php5 so scrapping that all and going back to 4 beause the app my client uses needs it] with that darned “Fatal error: Call to undefined function: xslt_create()” which i only worked out was an incompatibility issue with php 5 prob by coming here.. so cheers for getting me this far!!!

    I’ve even tried having the copying the php4ts.dll in sys32 and windows to hedge my bets to no avail.

  31. almas says:

    i am getting internal server error and when i start apache console the i get 2 screens one which is empty and gets closed very rapidly and another with following lines

    [Sat Mar 04 22:46:19 2006] [warn] (2)No such file or directory: exec() may not be safe
    Apache/1.3.31 (Win32) running…

  32. Ryan Hennessy says:

    Hello, I’m a developer with a managed server so I don’t know much about servers. We have a trade show coming up and need to run our site off of a laptop and your tutorial on setting up xslt/sablotron for windows saved me. Thanks,
    Ryan

  33. N Hamayun says:

    Yes , your page has proved to me a little helpfull.
    as i am using Apache/2.0.59 (Win32) PHP/5.1.6 , and there is no php_xslt.dll file in the ext folder of php but i found on php site file named php_xsl.dll will be used for xslt purpose so i tried whatever you said using this file. while using phpinfo(); method it shows the xsl support but when i browse your sample pages they donot show any thing except fatal error of xslt_create() not found at line at.
    please help me out as i am struggling to do my final year project and time is running out.
    also please note my php folder is c:\php and for apache is c:\Apache2

  34. Stefan says:

    Hello,
    I have a problem, I can’t configure my PHP 4.4 under Apache 2.2 with exsl suport. Can you help me?
    In phe.ini I have xsl, domxml support, but no exsl support.

    Thank you

  35. Javier says:

    Hi, I’m trying to use XSL on PHP5, but when I executed phpinfo() it don’t show me that I have installed the extension XSL, I already tried with this too “–with-xsl[=C:\wamp\php\ext]” in the PHP.INI but it don’t work, Any Idea? Sorry for the troubles and Thank you for your support.

  36. John says:

    I am just posting what my fix to this mess was. I am using XP SP2, apache 2, and php > 4.2.

    I was unable to get phpinfo() to show any proof that the xslt extension was working. I noticed that the php.ini location at the top just said C:\Windows\ and nothing else. So, I looked in my apache config and noticed that my PHPIniDir was pointing to /php, so to fix it, I changed it to C:/apache/php/php.ini And, like magic, it worked.

  37. satyendra Thakur says:

    Hi i am using php 5 and apache 2.2x getting error
    “can’t locate API module structure ‘php_module’ in file “c:/php/php5apache2_2_dll: No error

    Please help me out or send me how to configure it?

Leave a Reply

Miscellaneous

I use the Nokia e61i as my mobile. Instead of my telco’s data plan (which offers me a meagre 1GB per month) I simply prefer to use my home wireless [...]

Continue reading →

View all

Web Tools

If you use Firefox (and if not, what are you waiting for?) you are familiar with useful extensions such as Video Downloader, which allow you to save local copies of [...]

Continue reading →

View all

Databases

This regexp worked for me. SELECT * FROM table WHERE NOT column ~ ( ‘^(‘|| $$[\09\0A\0D\x20-\x7E]|$$|| — ASCII $$[\xC2-\xDF][\x80-\xBF]|$$|| — non-overlong 2-byte $$\xE0[\xA0-\xBF][\x80-\xBF]|$$|| — excluding overlongs $$[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|$$|| — straight 3-byte [...]

Continue reading →

View all

Windows

So you’ve been visited by the much dreaded CRC — Cyclical Redundancy Check error, most likely encountered while copying files between hard disks. On Mac OSX, this will usually appear [...]

Continue reading →

View all

Mac OSX

A simple app ought to do it. Download iRinger. It’s a Windows app. If you’re on Mac, you’ll want to use it within a virtual machine, like Parallels or VMWare [...]

Continue reading →

View all

System Maintenance

I use the Nokia e61i as my mobile. Instead of my telco’s data plan (which offers me a meagre 1GB per month) I simply prefer to use my home wireless [...]

Continue reading →

View all

Wordpress

Among many new exciting features, WordPress 2.6 released the ability to store each and every revision of your posts, like an elaborate update history. Now this can be a pretty [...]

Continue reading →

View all

Audio/Video

Panic, the makers of some fantastic software such as Transmit or Panic, also have the most light-weight audio converter for the Mac OSX platform. It’s called Audion: get it here. [...]

Continue reading →

View all

iPhone

A simple app ought to do it. Download iRinger. It’s a Windows app. If you’re on Mac, you’ll want to use it within a virtual machine, like Parallels or VMWare [...]

Continue reading →

View all