RE: [xsl] selecting an element in an external doc using its id attribute

Subject: RE: [xsl] selecting an element in an external doc using its id attribute
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 18 Jun 2002 08:52:20 +0100
The id() function works within the document containing the context node.
The expression you have used is legal in XPath 2.0, but not in 1.0. In
1.0, you have to use xsl:for-each to change the context node, and then
use the id() function - you can't use a function call on the rhs of the
"/" operator.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Cindy Mazza
> Sent: 17 June 2002 22:21
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] selecting an element in an external doc using 
> its id attribute
> 
> 
> Hi ,
> 
> 
> The following code gets me the first div3 element w/in the 
> odes document (as expected):
> 
>         <xsl:variable name="from" select="@from"/>
>         <xsl:variable name="docnode" 
> select="document('../texts/odes.xml')"/>
>         <xsl:message>
>           <xsl:value-of select="$docnode//div3"/>
>         </xsl:message>
> 
> But when I try to find an element whose id attribute is equal 
> to the value of the 'from' variable, I get an error saying 
> "Unexpected token [<function>] in path expression."
> 
>         <xsl:variable name="from" select="@from"/>
>         <xsl:variable name="docnode" 
> select="document('../texts/odes.xml')"/>
>         <xsl:message>
>           <xsl:value-of select="$docnode//id($from)"/>
>         </xsl:message>
> 
> Is it possible to do it this way, or do I need to go about it 
> differently? Either way, I'd appreciate any help.
> 
> Thanks.
> 
> ----- 
> - Cindy  
> 
> Cynthia L. Mazza
> mailto:clm6u@xxxxxxxxxxxx
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread