[Bug 8219] New: [XSLT] Shallow copy and xml:base

View: New views
4 Messages — Rating Filter:   Alert me  

[Bug 8219] New: [XSLT] Shallow copy and xml:base

by Bugzilla from bugzilla@wiggum.w3.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://www.w3.org/Bugs/Public/show_bug.cgi?id=8219

           Summary: [XSLT] Shallow copy and xml:base
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: PC
               URL: http://www.w3.org/TR/xslt20/#shallow-copy
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 2.0
        AssignedTo: mike@...
        ReportedBy: tim@...
         QAContact: public-qt-comments@...


The following paragraph towards the end of the Shallow copy section

"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."

is ambiguous in that it is unclear whether

"the case of an element node having an xml:base attribute"

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:

<?xml version="1.0"?>
<doc xml:base="http://source.base.uri">
  <inner xml:base="AAA/" />
</doc>

and the transformation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">

  <xsl:template match="/doc/inner">
     <xsl:variable name="target" as="element()">
       <xsl:copy xml:base="http://copy.base.uri">
         <xsl:attribute name="xml:base">BBB/</xsl:attribute>
       </xsl:copy>
     </xsl:variable>
     <out>
       <xsl:value-of select="base-uri($target)" />
     </out>
  </xsl:template>

</xsl:stylesheet>

Interpretation (1):

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

<out>http://copy.base.uri/AAA/</out>


Interpretation (2)

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

The result is therefore:

<out>http://copy.base.uri/BBB/</out>


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

<out>http://source.base.uriAAA/BBB</out>


--
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.


[Bug 8219] [XSLT] Shallow copy and xml:base

by Bugzilla from bugzilla@wiggum.w3.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://www.w3.org/Bugs/Public/show_bug.cgi?id=8219





--- Comment #1 from Michael Kay <mike@...>  2009-11-06 17:44:30 ---
Sorry, but I don'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 "The base URI of a node is copied ..." to "When a node
is copied, its base URI is copied, ...". Would that be clearer?


--
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.


[Bug 8219] [XSLT] Shallow copy and xml:base

by Bugzilla from bugzilla@wiggum.w3.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://www.w3.org/Bugs/Public/show_bug.cgi?id=8219


Oliver Hallam <oliver@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oliver@...




--- Comment #2 from Oliver Hallam <oliver@...>  2009-11-06 20:00:45 ---
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'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?


--
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.


[Bug 8219] [XSLT] Shallow copy and xml:base

by Bugzilla from bugzilla@wiggum.w3.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://www.w3.org/Bugs/Public/show_bug.cgi?id=8219


Michael Kay <mike@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




--- Comment #3 from Michael Kay <mike@...>  2009-11-06 22:13:15 ---
OK, I see the problem now. The current text is taken from the identical text
for the xsl:copy-of instruction, and it's written in the mistaken belief that
when you copy an element, you copy its attributes. So it's written to say that
the base-uri attribute of the element before copying should be used, but this
doesn'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.


--
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.