Subject: [xsl] Shallow copy and base URI From: Florent Georges <darkman_spam@xxxxxxxx> Date: Thu, 26 Jan 2006 23:51:01 +0100 (CET) |
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 : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs exceptionnels pour appeler la France et l'international. Tilichargez sur http://fr.messenger.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Returning HTML tags from , Michael Kay | Thread | Re: [xsl] Shallow copy and base URI, David Carlisle |
Re: [xsl] finding lowest level in a, David Carlisle | Date | Re: [xsl] finding lowest level in a, G. Ken Holman |
Month |