After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 654150 - apply-imports needs to consider built-in templates
apply-imports needs to consider built-in templates
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2011-07-07 11:36 UTC by Martin Honnen
Modified: 2016-06-21 12:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test stylesheet (347 bytes, application/xml)
2011-07-07 11:37 UTC, Martin Honnen
Details
test input XML document to be used with test stylesheet (28 bytes, application/xml)
2011-07-07 11:38 UTC, Martin Honnen
Details

Description Martin Honnen 2011-07-07 11:36:10 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
Comment 1 Martin Honnen 2011-07-07 11:37:28 UTC
Created attachment 191443 [details]
test stylesheet
Comment 2 Martin Honnen 2011-07-07 11:38:17 UTC
Created attachment 191444 [details]
test input XML document to be used with test stylesheet
Comment 3 Nick Wellnhofer 2016-06-21 12:26:47 UTC
Fixed with the following commit:

https://git.gnome.org/browse/libxslt/commit/?id=45ea7fc4554ee2f39f0a301346f7bd24108c8228