Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > <Need Help>How to read an element based on condition in XSLT?

Reply
Thread Tools

<Need Help>How to read an element based on condition in XSLT?

 
 
njsimha njsimha is offline
Junior Member
Join Date: Sep 2008
Posts: 3
 
      09-12-2008
Hi,
I have the following question:

XML snippet:

<root>

<template1>
<elem1>10</elem1>
<elem2>20</elem2>
<elem3>
<subelem1>65</subelem1>
<subelem2>65</subelem2>
</elem3>
</template1>

<template1>
<elem1>10</elem1>
<elem2>20</elem2>
<elem3>
<subelem1>45</subelem1>
<subelem2>15</subelem2>
</elem3>
<elem4>100</elem4>
</template1>

</root>

I want to check that elem4 must be present under template1 only if the value of subelem1 is < 60.If this condition fails then a error message has to be displayed.

I did the template match as follows:
<xsl:template match="/root/template1/elem3/subelem[. >60 ]/> but how to check the existense of elem4?

Please reply me how to achieve this in XSLT?

Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with while condition OR condition Bill W. Ruby 13 05-09-2011 09:42 PM
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
XPath expression for element based on content of other element withsame parent Ian Wilson XML 2 07-26-2007 04:11 PM
Find the first element that meets the condition jm.suresh@no.spam.gmail.com Python 3 02-25-2007 05:44 PM
Condition outside loop or separate loop for different condition? - Java 12 06-15-2005 08:50 AM



Advertisments