xsl-list
[Top] [All Lists]

RE: Shallow copy and base URI

2006-01-26 16:57:43
The statement

if the copied node is subsequently attached as a child to a new element, the
final copy of the node inherits its base URI from its parent node

is true but incomplete. Item 10 in 5.7.1 makes clear that the same thing
applies when it's attached to a document node. I've raised the comment to
get the spec clarified.

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

Michael Kay 

-----Original Message-----
From: Florent Georges [mailto:darkman_spam(_at_)yahoo(_dot_)fr] 
Sent: 26 January 2006 22:51
To: XSL Mulberry list
Subject: [xsl] Shallow copy and base URI

  Hi

  I have a little question about identity copy and base URI.
I have a module for the first pass of my pocessing, that
uses identity copy (and remove some elements).  That
intermediate result is put in a variable:

    <xsl:variable name="tree">
      <xsl:apply-templates mode="the.mode"/>
    </xsl:variable>

  The children of the document node are elements created by
xsl:copy.  The source document and the stylesheets are in
different directories.  The source tree (and thus the $tree
document node) can have descendants whose the @href is a
possibly relative URI that have to be used by fn:doc().

  But XSLT2/§11.9.1 says:

    The base URI of a node is copied. However, if the copied
    node is subsequently attached as a child to a new
    element, the final copy of the node inherits its base
    URI from its parent node, unless this is overridden
    using an xml:base attribute.

  Is "to a new element" including document nodes?  It is not
clear to me (I'd say no), but is what I observe with Saxon.
So without explicitely set the base URI, the base URI become
the one of the xsl:variable element.

  So how to set the base URI correctly?  I can't do the
following, because in the first one can't create an
attribute as child of a document node and in the second one
the xml:base value is not a correct URI:

    <xsl:variable name="tree">
      <xsl:attribute name="xml:base" select="base-uri()"/>
      <xsl:apply-templates mode="the.mode"/>
    </xsl:variable>

    <xsl:variable name="tree">
      <tree xml:base="{base-uri()}">
        <xsl:apply-templates mode="the.mode"/>
      </tree>
    </xsl:variable>

  So the only way to achive my goal is to use the following:

    <xsl:variable name="tree">
      <tree>
        <xsl:attribute name="xml:base" select="base-uri()"/>
        <xsl:apply-templates mode="the.mode"/>
      </tree>
    </xsl:variable>

  Or to have exactly the same result as expected at the
beginning, I have to use a temporary variable (to avoid to
create a document node):

    <xsl:variable name="tmp.tree">
      <tree>
        <xsl:attribute name="xml:base" select="base-uri()"/>
        <xsl:apply-templates mode="the.mode"/>
      </tree>
    </xsl:variable>

    <xsl:variable name="tree" select="$tmp.tree/tree/*"/>

  Is all this right?  Are document nodes concerned by the
paragraph cited above?  Is there a simpler way to achieve
the original goal?

  Thanks.  Regards,

--drkm



















      

      
              
______________________________________________________________
_____________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! 
Découvez les tarifs exceptionnels pour appeler la France et 
l'international.
Téléchargez sur http://fr.messenger.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>