Results 1 to 6 of 6

Thread: XSL transformation in PHP

  1. #1
    Join Date
    Aug 2005
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default XSL transformation in PHP

    I was wondering what type of XSL transformation is available - XSL, DOM, PCRE? I'm quite new to PHP, but I've got the XSL method figured out. However I've got a sneaky suspicion that this isn't enabled on the live servers. Here's the code I'm using:

    PHP Code:
    function TransformXml($xml_file$xsl_file$params)
    {
        
    $xp = new XsltProcessor();
        
    // create a DOM document and load the XSL stylesheet
        
    $xsl = new DomDocument;
        
    $xsl->load($xsl_file);
        
        
    // import the XSL stylesheet into the XSLT process
        
    $xp->importStylesheet($xsl);
        
        
    // create a DOM document and load the XML data
        
    $xml_doc = new DomDocument;
        
    $xml_doc->load($xml_file);
        
        
    // add parameters
        
    $namespace '';
        if (
    $params) {
            foreach (
    $params as $param => $value) {
                
    $xp->setParameter($namespace$param$value);
            }
        }
        
        
    // transform the XML into HTML using the XSL file
        
    if ($html $xp->transformToXML($xml_doc)) {
            return 
    $html;
        } else {
            
    trigger_error('XSL transformation failed.'E_USER_ERROR);
        }

    But this is the error I get:
    Fatal error: Class 'XsltProcessor' not found

    I've been looking through some phpinfo() on the live server, and comparing that to my dev server, and I reckon I'm missing this section:

    xsl
    XSL enabled
    libxslt Version 1.1.12
    libxslt compiled against libxml Version 2.6.17
    EXSLT enabled
    libexslt Version 1.1.12

    Any advice? How else can I do some reasonably easy xml/xsl => html transformations?

  2. #2
    Join Date
    Mar 2005
    Location
    Isle of Man
    Posts
    1,261
    Thanks
    3
    Thanked 24 Times in 24 Posts

    Default

    yep, I don't think libxslt is installed. don't think it would be too hard to do though. what do you think Warren

  3. #3
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by nick
    yep, I don't think libxslt is installed. don't think it would be too hard to do though. what do you think Warren
    Will be enabled by tomorrow morning.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  4. #4
    Join Date
    Aug 2005
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Brilliant! Many thanks.


  5. #5
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by Warren Ashcroft
    Will be enabled by tomorrow morning.
    Done - please let me know if its OK.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  6. #6
    Join Date
    Aug 2005
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Warren Ashcroft
    Done - please let me know if its OK.
    Yep - xsl transformation working. Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Merge XML and XSL with ASP
    By Rappie in forum ASP (VBScript)
    Replies: 4
    Last Post: 27th June 2006, 11:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •