This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re[2]: selecting an element in an external doc using its id attribute
- From: Cindy Mazza <clm6u at virginia dot edu>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 18 Jun 2002 09:42:14 -0400
- Subject: Re[2]: [xsl] selecting an element in an external doc using its id attribute
- Organization: IATH
- References: <94290089927.20020617172118@virginia.edu><3D0E6661.9050907@yahoo.de>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Thank you so much for your help - it worked beautifully - that's exactly what I needed.
JP> Cindy Mazza wrote:
>> 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>
>>
JP> You can't use id() this way. A slash '/' in an XPath mus be
JP> followed by another step, and functions, like id(), do not
JP> fall into this category (in XPath 1.0).
JP> Use either a predicete
JP> <xsl:message>
JP> <xsl:value-of select="$docnode//*[@id=$from]"/>
JP> </xsl:message>
JP> (supposed all your ID attributes are named "id")
JP> or change the context using an xsl:for-each:
JP> <xsl:message>
JP> <xsl:for-each select="$docnode">
JP> <xsl:value-of select="id($from)"/>
JP> </xsl:for-each>
JP> </xsl:message>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list