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 344183 - xsl:copy misses to copy attributes in the XSLT namespace
xsl:copy misses to copy attributes in the XSLT namespace
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: kbuchcik
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-06-07 17:45 UTC by kbuchcik
Modified: 2006-06-19 18:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description kbuchcik 2006-06-07 17:45:18 UTC
In xsltCopy() (transform.c) attributes in the XSLT are incorrectly
not copied over to the result tree:

if (!xmlStrEqual(attr->ns->href, XSLT_NAMESPACE)) {
  ret = xmlCopyProp(ctxt->insert, attr);
  ret->ns = xsltGetNamespace(ctxt, node, attr->ns, ctxt->insert);
}

The exclusion of attribute in the XSLT namespace applies only
to attributes of literal result elements, not to any other
attributes; e.g. not to attributes from the source tree.

Example:

Stylesheet
----------
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="foo">
    <xsl:copy>      
      <xsl:apply-templates select="@*"/>      
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:copy/>    
  </xsl:template>
  
</xsl:stylesheet>

Source doc
----------
<?xml version="1.0"?>
<foo xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:bar="zoo"/>

xsltproc's result
-----------------
<?xml version="1.0"?>
<foo/>

Expected result
---------------
<?xml version="1.0"?>
<foo xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:bar="zoo"/>

The implementation of xsl:copy-of seems to work OK - it copies over
such attributes.
Example:
<xsl:template match="foo">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
  </xsl:copy>
</xsl:template>
This will copy the XSLT attributes as well.
Comment 1 kbuchcik 2006-06-19 18:33:27 UTC
Fixed in CVS HEAD.

The current result:

<?xml version="1.0"?>
<foo xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:bar="zoo"/>