Subject:Trying to access the position of an element based on its attribute value Author:Thanuja Rao Date:28 Apr 2008 11:34 AM
Hi All,
My input XML looks like this where in there can be only one OUT containing SCORE="1" for a given ROOT
<ROOT>
<ANS>
<CH ID="0"/>
<CH ID="2"/>
<CH ID="1"/>
<CH ID="3"/>
</ANS>
<OUT SCORE="0"><COND>"0"</COND></OUT>
<OUT SCORE="1"><COND>"3"</COND></OUT>
<OUT SCORE="0"><COND>"1"</COND></OUT>
<OUT SCORE="0"><COND>"2"</COND></OUT>
</ROOT>
I want it to display the output as 'd'. Basically, what I am expecting here is the position of the CH element whose ID matches with the COND whose SCORE=1.
Any resolution to this problem at the earliest would be great.
Thank you so very much!
Regards,
Tan
Subject:Trying to access the position of an element based on its attribute value Author:Tony Lavinio Date:28 Apr 2008 10:33 PM
1. Which version of Stylus Studio are you using?
2. Is this a real problem, or are we helping you with your homework?
We've had several students asking for help with actual school assignments.
If this is just you learning XSLT, we apologize in advance.
Subject:Trying to access the position of an element based on its attribute value Author:(Deleted User) Date:29 Apr 2008 06:15 AM
Hi Thanuja,
if I understand it correctly, your "position of the CH element" is just the computation of count(../ANS/CH[@ID='$cond']/preceding-sibling::CH)+1