GNOME Bugzilla – Bug 529223
Top-level elements not in the XSLT namespace must be ignored
Last modified: 2008-05-13 14:44:36 UTC
Top-level elements not in the XSLT namespace must be ignored, but they're not. $ ./xsltproc/xsltproc --version Using libxml 20631, libxslt 10122 and libexslt 813 xsltproc was compiled against libxml 20631, libxslt 10122 and libexslt 813 libxslt 10122 was compiled against libxml 20631 libexslt 813 was compiled against libxml 20631 ./xsltproc/xsltproc - <<EOF <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>Hello </xsl:text> <xsl:if test="false()"> <xsl:text>world</xsl:text> </xsl:if> </xsl:template> <x:ignore xmlns:x="x"> <xsl:template match="/"> <!--this better not be here!--> </xsl:template> </x:ignore> </xsl:stylesheet> EOF compilation error: file - line 14 element template element template only allowed as child of stylesheet I would expect the above to produce "Hello ", ignoring the <x:ignore> element because XSL Transformations (XSLT) Version 1.0 (http://www.w3.org/TR/1999/REC-xslt-19991116), Section 2.2, says: 'In addition, the xsl:stylesheet element may contain any element not from the XSLT namespace, provided that the expanded-name of the element has a non-null namespace URI. ... Thus, an XSLT processor is always free to ignore such top-level elements, and must ignore a top-level element without giving an error if it does not recognize the namespace URI.' The impact is that I cannot comment out sections of my xslt code. This makes development and in-code documentation annoying. The problem also, potentially, impacts cool xslt documentation tools like: http://www.cranesoftwrights.com/resources/xslstyle/index.htm Note regarding the history of the bug. The bug occurs in (where I first noticed it): $ xsltproc --version Using libxml 20627, libxslt 10119 and libexslt 813 xsltproc was compiled against libxml 20627, libxslt 10119 and libexslt 813 libxslt 10119 was compiled against libxml 20627 libexslt 813 was compiled against libxml 20627 but does not occur in: $ xsltproc --version Using libxml 20616, libxslt 10111 and libexslt 809 xsltproc was compiled against libxml 20616, libxslt 10111 and libexslt 809 libxslt 10111 was compiled against libxml 20616 libexslt 809 was compiled against libxml 20616
Apparently simple but actually painful because, if the element is an extension then the normal processing must still occur. using a comment to embed the discarded part is IMHO way safer... Anyway that should be fixed in SVN revision 1472. thanks, Daniel