GNOME Bugzilla – Bug 654150
apply-imports needs to consider built-in templates
Last modified: 2016-06-21 12:26:47 UTC
The XSLT specification in http://www.w3.org/TR/xslt#built-in-rule says about the built-in templates: "The built-in template rules are treated as if they were imported implicitly before the stylesheet and so have lower import precedence than all other template rules." In my current understanding that means that the apply-imports instruction needs to consider built-in templates, as (http://www.w3.org/TR/xslt#apply-imports) "xsl:apply-imports processes the current node using only template rules that were imported into the stylesheet element". However xsltproc/libxslt does not seem to consider built-in template rules when executing apply-imports, as the test stylesheet <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="root"> <xsl:copy> <xsl:apply-imports/> </xsl:copy> </xsl:template> <xsl:template match="test"> <xsl:copy> <xsl:text>passed</xsl:text> </xsl:copy> </xsl:template> </xsl:stylesheet> when run against the test XML document <root> <test/> </root> with xsltproc/libxslt outputs <?xml version="1.0"?> <root/> while with other XSLT processors like Saxon or XslCompiledTransform it outputs <?xml version="1.0" encoding="utf-8"?><root> <test>passed</test> </root> Tested on Windows where xsltproc -version shows xsltproc was compiled against libxml 20706, libxslt 10126 and libexslt 815 libxslt 10126 was compiled against libxml 20706 libexslt 815 was compiled against libxml 20706
Created attachment 191443 [details] test stylesheet
Created attachment 191444 [details] test input XML document to be used with test stylesheet
Fixed with the following commit: https://git.gnome.org/browse/libxslt/commit/?id=45ea7fc4554ee2f39f0a301346f7bd24108c8228