RE: [xsl] select attribute value based on attribute value

Subject: RE: [xsl] select attribute value based on attribute value
From: "Tim Watts" <timw@xxxxxxx>
Date: Fri, 16 Mar 2001 09:33:55 +1100
Hi Alex,

I don't think there is anything wrong with the code structure or your XML.

It seems that the Xpath is wrong in the XSLT.

You test of "listOfelements/animal[@='frogKEY']" assuming the context to be
the node above "listOfelements", a context node different than
"../animal/@att1" where you seem to have assumed "animal" is the context

Prehaps you should change <xsl:value-of select="../animal/@att1" /> to
<xsl:value-of select="listOfelements/animal/@att1" />

(The test case doesn't change the context node to "animal" as you have
appeared to assume.)

Tim  Watts

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Alex Reuter
Sent: Friday, 16 March 2001 7:10 AM
To: xslMailList (E-mail)
Subject: [xsl] select attribute value based on attribute value

Hello List,
I am trying to select an attribute att1 from an animal,
<animal att1="frog" att2="frogKEY">45</animal>
<animal att1="dog" att2="dogKEY">55</animal>
<animal att1="cat" att2="catKEY">33</animal>
<animal att1="mouse" att2="mouseKEY">22</animal>

by first checking the value of att2.  So I need to display @att1 when
My code currently does the following
<xsl:if test="listOfelements/animal[@='frogKEY']"><xsl:value-of

Its not working for me, so my code is definately wrong.  Any suggestions
would be appreciated.

My general question is, how do i select the value of an attribute based on
the value of another attribute?
Would it make more sense to move these attributes into sub elements?


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread