This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

select attribute value based on attribute value


Hello List,
I am trying to select an attribute att1 from an animal,
<listOfelements>
<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>
<listOfelements>

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

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?

Thanks,
Alex


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]