#43289 [NEW]: xslt document('') function return just a part of template

From: Date: Wed, 14 Nov 2007 08:23:47 +0000
Subject: #43289 [NEW]: xslt document('') function return just a part of template
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119629@lists.php.net to get a copy of this message
From: maximchick at gmail dot com Operating system: Gentoo Linux PHP version: 5.2.5 PHP Bug Type: XSLT related Bug description: xslt document('') function return just a part of template Description: ------------ xsl:document('') function must return contents of the template itself when the argument is empty string, but when i'm trying to modify template DOM document('') returns contents of original xsl loaded by DOMDocument::load() without my modifications. Reproduce code: --------------- $ cat /tmp/template.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="document('')//xsl:*"><xsl:value-of select="name()"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template> </xsl:stylesheet> $cat /tmp/template.php <?php $xml = new DOMDocument; //empty document (our stylesheet parses itself) $xml->load('/tmp/template.xsl'); $xsl = new DOMDocument; $xsl->load('/tmp/template.xsl'); $xpath = new DOMXPath($xsl); $xpath->registerNamespace('xsl','http://www.w3.org/1999/XSL/Transform'); $xpath->query('//xsl:stylesheet')->item(0)->appendChild($xpath->query('//xsl:template')->item(0)->cloneNode(true)); echo $xsl->saveXML(); //output changed xsl document $proc = new XSLTProcessor(); $proc->importStylesheet($xsl); echo $proc->transformToXML($xml); ?> Expected result: ---------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="document('')//xsl:*"><xsl:value-of select="name()"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template> <xsl:template match="/"> <xsl:for-each select="document('')//xsl:*"><xsl:value-of select="name()"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template></xsl:stylesheet> xsl:stylesheet xsl:output xsl:template xsl:for-each xsl:value-of xsl:text xsl:output xsl:template xsl:for-each xsl:value-of xsl:text Actual result: -------------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="document('')//xsl:*"><xsl:value-of select="name()"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template> <xsl:template match="/"> <xsl:for-each select="document('')//xsl:*"><xsl:value-of select="name()"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template></xsl:stylesheet> xsl:stylesheet xsl:output xsl:template xsl:for-each xsl:value-of xsl:text -- Edit bug report at http://bugs.php.net/?id=43289&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43289&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43289&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43289&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43289&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43289&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43289&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43289&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43289&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43289&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43289&r=support Expected behavior: http://bugs.php.net/fix.php?id=43289&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43289&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43289&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43289&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43289&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43289&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43289&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43289&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43289&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43289&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43289&r=mysqlcfg

« previous php.bugs (#119629) next »