W3C home > Mailing lists > Public > public-qt-comments@w3.org > November 2010

[Bug 11325] New: [XSLT] Base URIs for copied nodes strangely inconsistent

From: <bugzilla@jessica.w3.org>
Date: Tue, 16 Nov 2010 15:04:34 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-11325-523@http.www.w3.org/Bugs/Public/>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=11325

           Summary: [XSLT] Base URIs for copied nodes strangely
                    inconsistent
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: All
               URL: http://www.w3.org/TR/xslt20/#shallow-copy
        OS/Version: Windows 3.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 2.0
        AssignedTo: mike@saxonica.com
        ReportedBy: zongaro@ca.ibm.com
         QAContact: public-qt-comments@w3.org


Consider the following stylesheet

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:template match="/" xml:base="http://wonka.com/">
    <xsl:variable name="v" as="element()*">
      <xsl:copy-of select="doc/ch"/>

      <xsl:copy-of select="doc/ch/gch"/>

      <xsl:for-each select="doc/ch">
        <xsl:copy>
          <xsl:copy-of select="@*"/>
        </xsl:copy>
      </xsl:for-each>

      <xsl:for-each select="doc/ch/gch">
        <xsl:copy>
          <xsl:copy-of select="@*"/>
        </xsl:copy>
      </xsl:for-each>
    </xsl:variable>

    <out>
      <xsl:value-of select="for $i in $v return base-uri($i)"/>
    </out>
  </xsl:template>
</xsl:stylesheet>

and input document

<doc xml:base="http://example.com/foo"><ch xml:base="bar/baz"><gch/></ch></doc>

According to the penultimate paragraph of 11.9.1,[1] "The base URI of a node is
copied, except in the case of an element node having an xml:base attribute, in
which case the base URI of the new node is taken as the value of the xml:base
attribute, resolved if it is relative against the base URI of the xsl:copy
instruction."  The last paragraph of 11.9.2[2] contains the same text, with
xsl:copy-of replacing xsl:copy.

So I believe that means the output in this case should be:

<?xml version="1.0" encoding="UTF-8"?><out>http://wonka.com/bar/baz http:/
/example.com/bar/baz http://wonka.com/bar/baz http://example.com/bar/baz</out>

Draft erratum XT.E42 - raised for bug 8219 - changes the text in 11.9.1 to
"When a node is copied, its base URI is copied, except when the result of the
xsl:copy instruction is an element node having an xml:base attribute, in which
case the base URI of the new node is taken as the value of its xml:base
attribute, resolved if it is relative against the base URI of the xsl:copy
instruction," but that doesn't appear to alter the expected output.

Obviously we've been over this text a couple of times now, but did the working
group really intend for the base URI of a copied element to have this quirky
behaviour, where the base URI is copied only if there is no xml:base attribute
in the content of the resultant node?

It feels rather odd to me that the base URI of the copied gch element should be
determined in such a different way from the base URI of the copied ch element. 
Either the working group feels the base URI from the input is more important or
the base URI from the instruction in the stylesheet is more important.  Right
now we have a mixed view.  I think the specification should either consistently
use the base URI of the xsl:copy/xsl:copy-of instruction as the base URI of the
new node or consistently use the base URI of the original node, and then
resolve any xml:base attribute against that to come up with the ultimate base
URI.

[1] http://www.w3.org/TR/xslt20/#shallow-copy
[2] http://www.w3.org/TR/xslt20/#copy-of

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Tuesday, 16 November 2010 15:04:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:08 GMT