From: "Robert Soesemann" <rsoesemann(_at_)sapient(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [xsl] Test for node name and attribute value
Date: Tue, 30 Nov 2004 12:51:53 +0100
Hello
I am stuck with the following node set expression.
In an external document I want to find the element which name is
'anchor' and which attribute @name has the value
of the variable $anchor.
I tried the following expression:
...
1 <xsl:for-each ...>
...
2 <xsl:variable name="anchor" select="@anchor"/>
3 <xsl:variable name="anchor-node" select="$external-doc//node()[name()
= 'my-anchor' and @name = $anchor]" />
...
4 </xsl:for-each>
--
By the way can remove line 2 and just rewrite line 3 to...?
3 <xsl:variable name="anchor-node" select="$external-doc//node()[name()
= 'my-anchor' and @name = @anchor]" />
Best regards,
Robert
Looks fine except that you said r=the name was "anchor" in the first bit but
you are testing against "my-anchor" in the second paart, you can also, I
believe, just search elements instead of all nodes by using:
select="$external-doc//*[name() = 'my-anchor' and @name = @anchor]"
--
Joe
--~------------------------------------------------------------------
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>
--~--