SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XSLTProcessor not working on WAMP

    Hi can anyone help I have an XML/XSL application which works well on our development server. These are the details of my development server

    Linux 2.6.9
    PHP 5.2.6
    xsl libexslt Version 1.1.11

    However when I try to run this same application on WAMP5 1.7.1 on my local machine - most of the XSL stuff doesn't work (1 script does work). These are the details of my personal dev server.

    Windows XP
    PHP 5.2.2
    xsl libexslt Version 0.8.13

    I have checked the with phpinfo function that XML and XSL is working.

    I made sure php_xsl.dll and php_domxml.dll extensions are enabled in php.ini.

    I raised the memory_limit in php.ini to 128MB.

    I downloaded and tested successfully a basic XSL script using XSLTProcessor.
    http://www.tanguay.info/wamp/installPhp5.php5?step=18

    However I am still having problems - what is the issue? do I need a more up to date XSLTProcessor or something?.

    Thanks
    Steven

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are the errors you are getting ?
    From what I see from the source you gave, this is the usual way to use the XSL engine from php.
    What are the other scripts ?

    I raised the memory_limit in php.ini to 128MB.
    You had memory errors ? If not, this will not do anything...

  3. #3
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not getting any errors (even though error reporting is enabled).

    The one script that works (sitemap) uses

    xsl:apply-templates
    xsl:attribute
    xsl:value-of
    xsl:when
    xsl:for-each

    The one thing the other scripts (which don't work) have in common is they use a variable (the page) and use xsl:call-template. Could this be the problem?


    PHP Code:
    function get_page() {  
       
    $this_page basename($_SERVER['SCRIPT_NAME']);    
       return 
    $this_page;
    }


    // load XML and XSL files
    function load_XML($load_xsl) {   
       
    // work out the page name
       
    $this_page get_page();
       
        
    // load the XML
       
    $xml = new DOMDocument;
       
    $xml->load('xml/structure.xml');
       
    $xsl = new DOMDocument;
       
       
    // load the XSL
       
    $xsl->load($load_xsl);
       
         
       
    // configure the transformer
       
    $proc = new XSLTProcessor;
       
    $proc->setParameter(null'this_page'$this_page);
       
    $proc->importStyleSheet($xsl); // attach the xsl rules   
       
    echo $proc->transformToXML($xml);


    And in the XSL

    Code:
    <!-- accept page name variable from web page -->
    <xsl:param name="this_page" />
    
    <!-- if the content page is at gallery primary -->
    <xsl:template match="/opml/body/outline/outline[@rel_url = $this_page]">       
       <!-- call the common code to create the list -->   
       <xsl:call-template name="gallery-primary-breadcrumb" />    
    </xsl:template>

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it could be that the xml+xsl result is a blank page.

    What you can do, to quick test your xsl style sheet, is to declare the xsl in the xml file, and to open the xml file in your browser, like this (example files taken from www.quixml.org, one of my projects):

    1.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE HTML>
    <?xml-stylesheet href="1.xsl" type="text/xsl"?>
    <ROOT>
     <GENERAL>
      <title>Quixml::Quick Xml and Xsl for PHP</title>
      <lng>en</lng>
      <nav>
       <link>
        <name>* home</name>
    
        <path>/</path>
        <target>_top</target>
       </link>
       <link>
        <name>* Usage manual</name>
        <path>/manual/</path>
        <target>_top</target>
    
       </link>
       <link>
        <name>* Class Documentation</name>
        <path>/doc/</path>
        <target>_top</target>
       </link>
       <link>
    
        <name>* Licence</name>
        <path>/LICENCE</path>
        <target>_top</target>
       </link>
       <link>
        <name>* Read Me</name>
        <path>/README</path>
    
        <target>_top</target>
       </link>
      </nav>
     </GENERAL>
     <DATAS/>
    </ROOT>
    and in 1.xsl:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--open
    08.11.2007, ts, Init 
    
     -->
    <xsl:stylesheet version="1.0" 
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    >
    <xsl:output method="html" encoding="UTF-8" indent="yes"
                doctype-public="-//W3C//DTD HTML 4.01//EN"
                doctype-system="http://www.w3.org/TR/html4/strict.dtd"
                standalone="yes" omit-xml-declaration="yes"
                />
    <xsl:template match="/">
      <html>
        <head>
          <title><xsl:value-of select="/ROOT/GENERAL/title"/></title>
          <xsl:call-template name="SCRIPTS"/>
          <xsl:call-template name="LINKS"/>
          <link rel="stylesheet" href="/doc/media/stylesheet.css" />
    
          <link rel="stylesheet" href="/doc/media/banner.css" />
          <link rel="stylesheet" href="/css/base.css" type="text/css"/>
          <link rel="shortcut icon" href="/favicon.ico" />
        </head>
        <body>
          <xsl:apply-templates select="ROOT"/>
        </body>
      </html>
    </xsl:template>
    
    <xsl:template match="ROOT">
      <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="GENERAL"/>
    <xsl:variable name="GENERAL" select="GENERAL"/>
    
    <!-- FROM INCLUDE  org.quixml.utils (html)-->
    <!-- org.quixml.utils
    5.12.2007 init.  Contains the lowercase/uppercase translation templates
    
    -->
    <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
    <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    
    <xsl:template name="navItem">
    
      <li>
        <a href="{path}" target="_top"><xsl:value-of select="name"/></a>
      </li>
    </xsl:template>
    <!-- END INCLUDE  org.quixml.utils-->
    
    <!-- com.quixml.index
    028.11.2007, ts, init
    
    -->
    <xsl:template name="SCRIPTS"/>
    <xsl:template name="LINKS"/>
    
    <xsl:template match="DATAS">
      <!-- FROM INCLUDE  org.quixml.header (html)-->
    <!--org.quixml.header
    18/01/2008, Thierry Schork, creation
    -->
    
    <div id="divNav">
      <ul>
        <xsl:for-each select="/ROOT/GENERAL/nav/link">
          <xsl:call-template name="navItem"/>
        </xsl:for-each>
      </ul>
    </div>
    <div style="position:fixed; top:15px; right:10px;">
    <form method="get" action="http://www.google.com/custom" target="_top">
    <table border="0" bgcolor="#cccccc">
    <tr><td nowrap="nowrap" valign="top" align="left" height="32">
    
    <br/>
    <input type="hidden" name="domains" value="www.quixml.org"></input>
    <label for="sbi" style="display: none">Enter your search terms</label>
    <input type="text" name="q" size="15" maxlength="255" value="" 
    id="sbi"></input>
    <label for="sbb" style="display: none">Submit search form</label>
    <input type="submit" name="sa" value="Google Search" id="sbb"></input>
    </td></tr>
    <tr>
    <td nowrap="nowrap">
    <table>
    <tr>
    <td>
    <input type="radio" name="sitesearch" value="" checked="checked" id="ss0"></input>
    <label for="ss0" title="Search the Web"><font size="-1" 
    color="black">Web</font></label></td>
    
    <td>
    <input type="radio" name="sitesearch" value="www.quixml.org" 
    id="ss1"></input>
    <label for="ss1" title="Search www.quixml.org"><font size="-1" 
    color="black">www.quixml.org</font></label></td>
    </tr>
    </table>
    <input type="hidden" name="client" value="pub-9456079055461741"></input>
    <input type="hidden" name="forid" value="1"></input>
    <input type="hidden" name="channel" value="7738231454"></input>
    <input type="hidden" name="ie" value="ISO-8859-1"></input>
    <input type="hidden" name="oe" value="ISO-8859-1"></input>
    <input type="hidden" name="cof" 
    value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input>
    <input type="hidden" name="hl" value="en"></input>
    </td></tr></table>
    </form>
    </div>
    <br style="clear:both"/>
    
    <!-- SiteSearch Google -->
    
    <!-- END INCLUDE  org.quixml.header--> 
    <div style="font-size:.8em">
    <h2>Looking for the Ruby quixml API?</h2>
    <p>
      Then you will find it on <a href="http://quixml.rubyforge.org/">quixml.rubyforge.org</a>
    </p>
    </div>
    <h1>Quixml: A PHP class to ease the XML + XSL development</h1>
    <p>
      Welcome to Quixml.org.<br/>
    
      Quixml is a PHP class that I developped upon personal curiosity to exploit a perfect separation between logic
      and presentation layers.<br/>
      XML and XSL have been designed to answer that question, and after having struggled for a long time with numerous templateing framework for PHP, 
      I decided to code this library because nothing I found either worked or simply did what I was looking for.
    </p>
    <h2>Changelog</h2>
    <div class="date">20/01/2008</div>
    <p>
      The manual has been rewrote, and I hope it&apos;s a bit more cleare now.<br/>
    </p>
    <h2>Goal</h2>
    
    <p>
      The goal of this class is to provide a simple way to output XML, and to associate an SL stylesheet.<br/>
      The class detect itself if the XML should be transformed to HTML (or any other output type, this is configurable) and let you concentrate on the
      data retrieval rather than the inner structure of your XML file.
    </p>
    
    <h2>Requirements</h2>
    <p>
      This class have a few requirements, and your PHP installation needs to honnor them before you can use it.<br/><br/>
      Imperative requirement:
    </p>
    
      <ol>
        <li>You must have PHP 5.0 at least. This library is not compatible with PHP 4.<br/>Too many chanegs have occured in the XML and XSL extensions between the 2 versions.</li>
        <li>You must ahve the XMLWriter extension active. This class is built around it. This requirement is meant to be dropped in the future.</li>
      </ol>
    <p>
      In addition, the XSL generation process allows you to "include" separate files in 1.
      This process can be time consuming on large stylesheets.<br/>
      To lighten up the generation process, a caching mechanism have been implemented, which use PDO and Sqlite to store the merged stylsheets.
      If you want/plan to use this caching mechanism, then you will need
    
    </p>
      <ol>
        <li>PDO as the database framework</li>
        <li>PDO:Sqlite as the PDO driver</li>
      </ol>
    <p>
      <a href="http://www.sqlite.org">Sqlite</a> is a lightweight database stored in a file. 
    </p>
    
    <h2>Download</h2>
    <p>
      18/01/2008: <a href="/quixml.zip">Latest version (development)</a>
    </p>
    <h2>From here...</h2>
    <p>
      You can visit the <a href="/manual/" target="_top">manual</a> (sorry for the mess, but I&apos;m working on it) or go directly to the <a href="/doc/" target="_top">class reference</a>.<br/>
    
      Future annoucements will be made here. 
    </p>
    </xsl:template>
    
    <!--close
    08.11.2007, ts, Init 
     -->
    </xsl:stylesheet>
    Then, drop the xml file on ie or firefox, and if there are errors in it, they will tell it to you.
    And you can see the xsl transform result instantly too.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice. My test script seems fine - it must be something to do with the XSLT processor not running that particular script. Is it something to do with that page name parameter.

    I can echo out the page name both in the PHP and XSL - so I don't know what the problem is.

    PHP Code:
    function get_page() {  
       
    $this_page basename($_SERVER['SCRIPT_NAME']);    
       return 
    $this_page;

       echo 
    $this_page;
    }


    // load XML and XSL files
    function load_XML($load_xsl) {   
       
    // work out the page name
       
    $this_page get_page();
       
        
    // load the XML
       
    $xml = new DOMDocument;
       
    $xml->load('xml/structure.xml');
       
    $xsl = new DOMDocument;
       
       
    // load the XSL
       
    $xsl->load($load_xsl);
       
         
       
    // configure the transformer
       
    $proc = new XSLTProcessor;
       
    $proc->setParameter(null'this_page'$this_page);
       
    $proc->importStyleSheet($xsl); // attach the xsl rules   
       
    echo $proc->transformToXML($xml);




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
  •