473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to read an element based on condition in XSLT

17
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.
Sep 12 '08 #1
1 1887
Dormilich
8,658 Expert Mod 8TB
I did the template match as follows:
<xsl:template match="/root/template1/elem3/subelem[. >60 ]/> but how to check the existense of elem4?
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="//subelem1[text() &lt; 60 ][//elem4]>
This applies if subelem1 and elem4 occur only once. If they must be siblings I'll consider that in a following post.

regards

PS: please use [code] tags when posting code
Sep 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
1
by: Igor | last post by:
Is there any way to resort and xml document using xslt based on element position. For example if I have xml like this: <root> <element> 1st thing </element> <element> 2nd thing </element>...
1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
4
by: ina | last post by:
Hello all, I am newbie in xml and have a problem with this parse. I have this xml.file <Style> <Strategy>
6
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, can someone please let me know how I can read xml elements using object oriented program. I created a class to use the get and set properties however I dont know how I can pass the values from...
6
by: John Larson | last post by:
Hi All, I am some information from INSPEC database records in XML to build a relational database of my own. I am currently trying to extract information by doing an XSLT transform of the XML...
2
by: njsimha | last post by:
Hi, I have a query regarding the selection of a particular tag based on a condition. In the following XML code: <root> <template1> <elem1>1000</elem1> <elem2>
3
by: abhijeetraje | last post by:
I am applying XSLT to WSDL to generate html pages. now, as WSDL is not having comprehensive details, i am adding XML documentation (.NET) as well in XSLT. like this.. <xsl:variable name="ddoc"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.