#32604 [NEW]: generate-id() XSL function generates a different id for the same node each time
| From: | alex dot bazan at wanadoo dot es | Date: | Wed, 06 Apr 2005 10:42:20 +0000 |
| Subject: | #32604 [NEW]: generate-id() XSL function generates a different id for the same node each time | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-76431@lists.php.net to get a copy of this message | ||
From: alex dot bazan at wanadoo dot es
Operating system: MandrakeLinux 10.1
PHP version: 5.0.4
PHP Bug Type: XSLT related
Bug description: generate-id() XSL function generates a different id for the same node each time
Description:
------------
Since the xslt functions are no longer bundled with PHP, i'm moving my
code to the XSLTProcessor class.
When i used the xslt functions, the XSL generate-id() function always
returned me the same auto-generated id for the same node, so i was able to
send the id to other pages and use it to process the XML.
With the XSLTProcessor classes, every time i reload the page it gives me a
new id for each node, so the generated ids are of no use.
Reproduce code:
---------------
<?php
$xmlDoc=<<<END_XML
<?xml version='1.0'?>
<mydoc>
<name>Alex</name>
<name>Gilad</name>
<name>Abdul</name>
<name>Diego</name>
</mydoc>
END_XML;
$xslDoc=<<<END_XSL
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0' xmlns="http://www.w3.org/TR/xhtml1/transitional"
exclude-result-prefixes="#default">
<xsl:output method="html" encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>
<xsl:template match="mydoc">
<table border="0">
<xsl:apply-templates select="*"/>
</table>
</xsl:template>
<xsl:template match="name">
<xsl:variable name="uniqueid"><xsl:value-of
select="generate-id(.)"/></xsl:variable>
<tr>
<td><xsl:value-of select="."/> (generated id=<xsl:value-of
select="\$uniqueid"/>)</td>
</tr>
</xsl:template>
</xsl:stylesheet>
END_XSL;
$xml=new DOMDocument();
$xml->loadXML($xmlDoc);
$xsl=new XSLTProcessor();
$xsl->importStylesheet(DOMDocument::loadXML($xslDoc));
echo $xsl->transformToDoc($xml)->saveXML()
?>
Expected result:
----------------
Expected:
First execution:
Alex (generated id=id2299486)
Gilad (generated id=id2299489)
Abdul (generated id=id2299492)
Diego (generated id=id2273414)
Second execution:
Alex (generated id=id2299486)
Gilad (generated id=id2299489)
Abdul (generated id=id2299492)
Diego (generated id=id2273414)
Actual result:
--------------
Actual result:
First execution:
Alex (generated id=id2299486)
Gilad (generated id=id2299489)
Abdul (generated id=id2299492)
Diego (generated id=id2273414)
Second Execution:
Alex (generated id=id2431192)
Gilad (generated id=id2431196)
Abdul (generated id=id2431199)
Diego (generated id=id2431202)
--
Edit bug report at http://bugs.php.net/?id=32604&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32604&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32604&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32604&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32604&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32604&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32604&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32604&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32604&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32604&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32604&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32604&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32604&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32604&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32604&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32604&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32604&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32604&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32604&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32604&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32604&r=mysqlcfg