473,385 Members | 1,796 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,385 software developers and data experts.

XPath: How to select all nodes which don't have children`

I have:

<data>
<item>
<object>bla</object>
</item>
<item>
</item>
<item>
<object>blabla</object>
</item>

now I want to build 2 lists with <xsl:for-each>
the first list should only display all items which have children
the second list should only dipslay all items which don't have children-

The first one I got myslef with:
<xsl:for-each select="/data/item/object/.."> ...

But the second list I cannot create
I thought about
<xsl:for-each select="/data/item/not(object)/..">

but it does not compile

Any help?

Thanks
Hannes
Jul 20 '05 #1
1 4138


Hannes Heckner wrote:
I have:

<data>
<item>
<object>bla</object>
</item>
<item>
</item>
<item>
<object>blabla</object>
</item>

now I want to build 2 lists with <xsl:for-each>
the first list should only display all items which have children
the second list should only dipslay all items which don't have children-

The first one I got myslef with:
<xsl:for-each select="/data/item/object/.."> ...
I think you want
/data/item[object]
But the second list I cannot create
I thought about
<xsl:for-each select="/data/item/not(object)/..">


That should be
/data/item[not(node())]
if you want the empty <item> elements. However some implementations
count white space as text nodes so make sure you write
<item></item>
to markup empty elements or use
/data/item[not(*)]
to select the <item> elements that do not contain elements

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Fish | last post by:
Hi, I just found this template in someone else's xslt (it's Microsoft's "word2html" stylesheet to convert WordProcessingML to HTML) <xsl:template match="WX:sect"> <xsl:variable...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
8
by: Michael Wohlwend | last post by:
Hi, this is my first xpath try and after reading many web-pages that xpath is still not working :-( (btw, it's my own project, not a homework) I have something like that: <root> <one/>
4
by: cgaden | last post by:
Hi everyone, I have a problem that I've been trying to figure out for a while but I just can't seem to get it right. I have the following XML fragment: <Page ID="x1" Schema="Folder"> -<Page...
13
by: David Thielen | last post by:
XPathNavigator nav = MyCreateNav(); // InnerXml == "software" nav.SelectSingleNode"."); The select returns an exception: + $exception {"'.' has an invalid token."} System.Exception...
2
by: Candle | last post by:
I am new to XML Programming and I am hoping someone can help me out with this. Assuming I have the following XML: <root> <E C="P_E1" O="E1" Y='True'> <A C="P_E1A1" V="7" Y='True'/> <A...
5
by: tschulken | last post by:
I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml <S3Client> <Buttons>...
3
by: Arndt Jonasson | last post by:
Let's say we have a schema (maybe expressed in XML Schema, but not necessarily so), that allows this instance document: <top> <txt>This is text</txt> <books> <book>Tarzan</book> <book>Harry...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.