XSL generate-id problems

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I used the xslt functions with php4... now i've moved to php5, and, as
the xslt functions are no longer bundled, i'm moving the code to the
XSLTProcessor class.

I've found a problem with the generate-id() XSL function... with the old
functions, generate-id() gave me the same id for the same section of my
XML document every time i processed it. Now, with the XSLTProcessor
class, every time it gives me a new id.

This is not how it's supposed to work, as it is impossible to make
references to sections of the document.

Am i doing something wrong or the new classes are a bit buggy?


Re: XSL generate-id problems

En/na alex bazan ha escrit:
Quoted text here. Click to load it

I've done a bit of code for anyone who wants to test this one. I also
will be opening a bug report in php.net...

Execute the script and refresh. The ids are change each time the page is
refreshed, when they should stay the same for each node.


<?xml version='1.0'?>

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform "
                 xmlns="http://www.w3.org/TR/xhtml1/transitional "

   <xsl:output method="html" encoding="ISO-8859-1"/>
   <xsl:strip-space elements="*"/>

    <xsl:template match="mydoc">
        <table border="0">
            <xsl:apply-templates select="*"/>

    <xsl:template match="name">
        <xsl:variable name="uniqueid"><xsl:value-of
            <td><xsl:value-of select="."/> (generated id=<xsl:value-of


$xml=new DOMDocument();

$xsl=new XSLTProcessor();
echo $xsl->transformToDoc($xml)->saveXML()


Site Timeline