xsl-list
[Top] [All Lists]

Re: Test for node name and attribute value

2004-11-30 05:01:42
  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[(_at_)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[(_at_)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[(_at_)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
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--