<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>8219</bug_id>
          
          <creation_ts>2009-11-06 17:33:20 +0000</creation_ts>
          <short_desc>[XSLT] Shallow copy and xml:base</short_desc>
          <delta_ts>2010-07-20 16:04:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 2.0</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.w3.org/TR/xslt20/#shallow-copy</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>oliver</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>29398</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2009-11-06 17:33:20 +0000</bug_when>
    <thetext>The following paragraph towards the end of the Shallow copy section

&quot;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. If the copied node is subsequently attached as a child to a new element or document node, the final copy of the node inherits its base URI from its parent node, unless this is overridden using an xml:base attribute.&quot;

is ambiguous in that it is unclear whether

&quot;the case of an element node having an xml:base attribute&quot;

refers to:

(1) an xml:base attribute of the element being copied, OR
(2) an xml:base attribute in the content sequence contained in the xsl:copy.


Consider the source document:

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;doc xml:base=&quot;http://source.base.uri&quot;&gt;
  &lt;inner xml:base=&quot;AAA/&quot; /&gt;
&lt;/doc&gt;

and the transformation:

&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
                version=&quot;2.0&quot;&gt;

  &lt;xsl:template match=&quot;/doc/inner&quot;&gt;
     &lt;xsl:variable name=&quot;target&quot; as=&quot;element()&quot;&gt;
       &lt;xsl:copy xml:base=&quot;http://copy.base.uri&quot;&gt;
         &lt;xsl:attribute name=&quot;xml:base&quot;&gt;BBB/&lt;/xsl:attribute&gt;
       &lt;/xsl:copy&gt;
     &lt;/xsl:variable&gt;
     &lt;out&gt;
       &lt;xsl:value-of select=&quot;base-uri($target)&quot; /&gt;
     &lt;/out&gt;
  &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;

Interpretation (1):

The xml:base attribute is &quot;AAA/&quot;
Resolving against the base URI of xsl:copy gives &quot;http://copy.base.uri/AAA/&quot;.
The result is therefore:

&lt;out&gt;http://copy.base.uri/AAA/&lt;/out&gt;


Interpretation (2)

The xml:base attribute is &quot;BBB/&quot;
Resolving against the base URI of xsl:copy gives &quot;http://copy.base.uri/BBB/&quot;.

The result is therefore:

&lt;out&gt;http://copy.base.uri/BBB/&lt;/out&gt;


I suspect that interpretation 2 is correct, however, when I&apos;ve tried this with an XSLT 2.0 implementation, the result was:

&lt;out&gt;http://source.base.uriAAA/BBB&lt;/out&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29399</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-11-06 17:44:30 +0000</bug_when>
    <thetext>Sorry, but I don&apos;t see how any reasonable reader could arrive at interpretation 2. It seems to me perfectly clear that interpretation 1 is correct.

I guess we could change &quot;The base URI of a node is copied ...&quot; to &quot;When a node is copied, its base URI is copied, ...&quot;. Would that be clearer?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29409</commentid>
    <comment_count>2</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2009-11-06 20:00:45 +0000</bug_when>
    <thetext>Let me summarize the effects of the two interpretations:

Interpretation 1:
  a) If the source node has a relative xml:base attribute then the base URI is computed with this uri resolved against the uri of the xsl:copy instruction.  The xml:base attribute itself is not copied.

  b) Otherwise the base URI of the source node is used.

  c) xml:base attributes that appear in the copied node are ignored for purposes of computing the node&apos;s base URI.


Interpretation 2:
  a) If the copied node has an xml:base attribute then this is resolved against the base URI of the xsl:copy instruction. 

  b) Otherwise the base URI of the source node is used.


Surely the intention of this sentence was interpretation 2 and it was just poorly worded?

If the intention was indeed interpretation 1, then what was the justification for adding this condition?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29415</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2009-11-06 22:13:15 +0000</bug_when>
    <thetext>OK, I see the problem now. The current text is taken from the identical text for the xsl:copy-of instruction, and it&apos;s written in the mistaken belief that when you copy an element, you copy its attributes. So it&apos;s written to say that the base-uri attribute of the element before copying should be used, but this doesn&apos;t make sense, because the intent of the rule is that the base URI of an element should always be consistent with its xml:base attribute if it has one, and in this case the xml:base attribute of the new node is not the same as the xml:base attribute of the old one.

So we should probably change the sentence

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.

to read

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.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35673</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-05-13 16:45:24 +0000</bug_when>
    <thetext>The change in comment #3 was approved by the WG. An erratum will be drafted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36889</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-07-15 08:54:21 +0000</bug_when>
    <thetext>Erratum E42 will be raised as described in comment #3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37017</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2010-07-20 16:04:42 +0000</bug_when>
    <thetext>Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>