|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-14 16:06 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 19:00:01 2025 UTC |
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