<need help>How to print the preceding node value based on descendant node in XSLT?

Joined
Sep 12, 2008
Messages
3
Reaction score
0
Hi,
In the folowing XML snippet:

Code:
<template1>
<name>student</name>
<elem1>
<[B]subelem1[/B]>65</[B]subelem1[/B]>
<subelem2>15</subelem2>
</elem1>
<[B]elem2[/B]>100</[B]elem2[/B]>
</template1>

</root>

For the above code,I need to display an error:
"elem2 node is not allowed for name=student as subelem1 is greater than 50"

so the requirement is,elem2 should not be present if subelem1 is > 50.

I have the following XSLT code:

<xsl:template match="/root/template1/elem1/subelem1">
<xsl:variable name="value" select="." />
<xsl:if test="$value > 50" >
subelem1 is greater than 50
<xsl:if test="../../elem2" >
<xsl:message terminate="yes">
<xsl:value-of select="concat("elem2 is not allowed for name=....")/>
elem4 exists
</xsl:if>
</xsl:if>
</xsl:template>

Using the above code,I am able to print the error as "elem2 is not allowed for name= ".
Here I am not able to print "name=student".How to print the value of name node?

Also please note that there will be 10 <template1> nodes.so the XSLT has to work for each template1.

Please reply me how to achieve this.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top