Subject: Re: Test for node name and attribute value
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 30 Nov 2004 12:01:42 GMT
|
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.
If I understand you correctkly you just want
<xsl:variable name="anchor-node"select="$external-doc//anchor[@name=$anchor]"/>
I in your code fragments you seem to have switched to looking for name
my-anchor rather than anchor.
3 <xsl:variable name="anchor-node" select="$external-doc//node()[name()
= 'my-anchor' and @name = $anchor]" />
that is legal but there is no need to select all nodes withg node() then
filter out those with name my-anchor, you could just do
3 <xsl:variable name="anchor-node" select="$external-doc//my-anchor[@name = $anchor]" />
which is more or less as above.
<xsl:variable name="anchor-node" select="$external-doc//node()[name()
= 'my-anchor' and @name = @anchor]" />
or
<xsl:variable name="anchor-node" select="$external-doc//my-anchor[@name = @anchor]" />
is also legal but tests the anchor attribute of the my-anchor element in
$external-doc is equal to the name attribute on the smae element.
David
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
|