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

Counting Empty nodes - xsl

Given a sample like the one below, how can I count the number of
elements <quick> with the value 'yes'. When processing the //quick
nodes I can easily find out if they are 'empty' but I need to write a
select pattern to see if any of them is not 'empty'. In the below
example the result should be '1' for the <quick>yes</quick> element
and '2' for the total count of <quick> elements. I tried various
implementations of
<xsl:value-of select="count(//sub[quick='yes'])"/> and the like,
including node() stuff (not allowed in patterns), but the, probably
simple, solution simply eludes me.

<?xml version="1.0" encoding="UTF-8"?>
<anything>
<sub>
<quick/>
</sub>
<sub>
<quick>yes</quick>
</sub>
</anything>
Jul 20 '05 #1
1 1362
anonymous wrote:
*Given a sample like the one below, how can I count the number of
elements <quick> with the value 'yes'. When processing the //quick
nodes I can easily find out if they are 'empty' but I need to writ
a
select pattern to see if any of them is not 'empty'. In the below
example the result should be '1' for the <quick>yes</quick> element
and '2' for the total count of <quick> elements. I tried various
implementations of
<xsl:value-of select="count(//sub[quick='yes'])"/> and the like,
including node() stuff (not allowed in patterns), but the, probably
simple, solution simply eludes me.

<?xml version="1.0" encoding="UTF-8"?>
<anything>
<sub>
<quick/>
</sub>
<sub>
<quick>yes</quick>
</sub>
</anything>

-
fpmurph
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message84317.htm

Jul 20 '05 #2

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

Similar topics

4
by: Jyrki Keisala | last post by:
Hi, I have an XML file which I want to present as a HTML table, and I'm looking for a quick way of defaulting all empty elements in my XML file to a nbsp (using the   notation) in my XSL...
4
by: dd | last post by:
Given the bolow sample, I need to count the elements <quick> with a child 'yes'. The result for this sample should, of couse, be '1', but I cannot figure out how to write the expression in the...
4
by: n_o_s_p_a__m | last post by:
My xml doc has many <title></title> and <title> in it, meaning the nodes have no content (although some do). How can I test for this? I tried title (doesn't work) I tried //title (doesn't work)...
1
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage...
1
by: Sonu Kapoor | last post by:
Hi guys, I know that counting of nodes is not a big deal. But I need to do something where I cant get any solution. Here is how my xml looks like. <?xml version="1.0" encoding="utf-8"?>...
6
by: Pavils Jurjans | last post by:
Hello, Here's the sample XML: <sample1></sample1> <sample2/> From many XML books and online documentations, it is said to be just different syntax for the same data. However, when we...
1
by: tMan | last post by:
whats the xpath to get all the empty nodes in a document. in the xml below i want to get the nodes <empty> and <t> all other nodes either have a child node or text in them <root> <test> <se>...
5
by: jhurrell | last post by:
I have an XML file that contains some empty nodes like: <sample> <test/> <test1/> </sample> I am using Saxon 8.8 to transform this XML into another XML file, but I'd like to remove...
11
by: David | last post by:
Hi All, I am working on a script that is theoreticaly simple but I can not get it to work completely. I am dealing with a page spit out by .NET that leaves empty tags in the markup. I need a...
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: 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:
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
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?
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.