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 764411 - multiple attribute sets with the same attribute: wrong attribute chosen
multiple attribute sets with the same attribute: wrong attribute chosen
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Mac OS
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-31 11:45 UTC by Mike Sulyaev
Modified: 2016-06-21 13:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
764411-test.zip (657 bytes, application/octet-stream)
2016-03-31 11:48 UTC, Mike Sulyaev
Details

Description Mike Sulyaev 2016-03-31 11:45:05 UTC
A literal output element with two attribute sets listed in xsl:use-attribute-set receives a merged set of attributes from both sets. 

Should the same attribute appear in both sets, the one from the set mentioned last in xsl:use-attribute-set should win. This is not what xsltproc does, and I think this is a bug.

Core of the sample:

  <xsl:template match="a">
    <b xsl:use-attribute-sets="att1 att2"/>
  </xsl:template>

  <xsl:attribute-set name="att1">
    <xsl:attribute name="att1">1</xsl:attribute>
    <xsl:attribute name="commonatt"><xsl:message>Applying @commonatt from att1 set</xsl:message>v1</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="att2">
    <xsl:attribute name="att2">2</xsl:attribute>
    <xsl:attribute name="commonatt"><xsl:message>Applying @commonatt from att2 set</xsl:message>v2</xsl:attribute>
  </xsl:attribute-set>

Result from xsltproc:
$ xsltproc a.xsl a.xml
Applying @commonatt from att1 set
<?xml version="1.0"?>
<b att1="1" commonatt="v1" att2="2"/>

Expected result (correct from saxon 6.5.5):
$ java -jar ~/lib/saxon.jar a.xml a.xsl 
Applying @commonatt from att1 set
Applying @commonatt from att2 set
<?xml version="1.0" encoding="utf-8"?>
<b att1="1" commonatt="v2" att2="2"/>

Note: not only the wrong value is chosen for @commonatt, but also the side effect is skipped by xsltproc.

The defect is present in (OS X):
$ xsltproc --version
Using libxml 20900, libxslt 10128 and libexslt 817
xsltproc was compiled against libxml 20900, libxslt 10128 and libexslt 817
libxslt 10128 was compiled against libxml 20900
libexslt 817 was compiled against libxml 20900,

as well as in (Linux):
$ xsltproc --version
Using libxml 20901, libxslt 10128 and libexslt 817
xsltproc was compiled against libxml 20901, libxslt 10128 and libexslt 817
libxslt 10128 was compiled against libxml 20901
libexslt 817 was compiled against libxml 20901

Ratio: https://www.w3.org/TR/xslt#attribute-sets: "Specifying a use-attribute-sets attribute is equivalent to adding xsl:attribute elements for each of the attributes in each of the named attribute sets to the beginning of the content of the element with the use-attribute-sets attribute, *in the same order* in which the names of the attribute sets are specified in the use-attribute-sets attribute." The spec regarding the order of addition is not satisfied.

Regards,
Mike
Comment 1 Mike Sulyaev 2016-03-31 11:48:48 UTC
Created attachment 325077 [details]
764411-test.zip
Comment 2 Mike Sulyaev 2016-03-31 11:50:23 UTC
Could be related to https://bugzilla.gnome.org/show_bug.cgi?id=704071 .
Comment 3 Nick Wellnhofer 2016-06-21 12:24:57 UTC
Fixed with the following commit:

https://git.gnome.org/browse/libxslt/commit/?id=05f70130433478c1075ce8b6fdc4c4dadf51d33e
Comment 4 Mike Sulyaev 2016-06-21 13:57:29 UTC
Thank you, works fine!