RE: [xsl] Test for node name and attribute value

Subject: RE: [xsl] Test for node name and attribute value
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Tue, 30 Nov 2004 14:18:25 +0100
Thanks for you reply.
I don't know why but node matches don't work when I use the simple
syntax:

my-relation

instead of

node()[name(.)='my-relation'

Is there something wron with my xsl transformer?

R.

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Dienstag, 30. November 2004 13:02
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Test for node name and attribute value


  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
________________________________________________________________________

Current Thread