xsl-list
[Top] [All Lists]

RE: Test for node name and attribute value

2004-11-30 06:18:25
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(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Dienstag, 30. November 2004 13:02
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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[(_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>
--~--


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