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
<xsl:template select="????">
I tried count(//quick/*) >0
which returns false...
<?xml version="1.0" encoding="UTF-8"?>
<dffob>
<destinations>
<dest>
<quick/>
</dest>
<dest>
<quick>yes</quick>
</dest>
</destinations>
</dffob> 4 1596
* dd wrote in comp.text.xml: 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 <xsl:template select="????"> I tried count(//quick/*) >0
* only matches element nodes while "yes" is a text node. You can
count(//quick/text())
But that would also count
<quick> </quick>
So
count(//quick[.="yes"])
might be better.
Bjoern Hoehrmann wrote: * dd wrote in comp.text.xml:
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 <xsl:template select="????"> I tried count(//quick/*) >0
* only matches element nodes while "yes" is a text node. You can
count(//quick/text())
But that would also count
<quick> </quick>
So
count(//quick[.="yes"])
might be better.
Tried this also:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="count(//quick[. ='yes'])"/>
</xsl:template>
</xsl:stylesheet>
Oxygen returns: value is not a node set
dd wrote: Bjoern Hoehrmann wrote:
* dd wrote in comp.text.xml:
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 <xsl:template select="????"> I tried count(//quick/*) >0 * only matches element nodes while "yes" is a text node. You can
count(//quick/text())
But that would also count
<quick> </quick>
So
count(//quick[.="yes"])
might be better.
Tried this also: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates select="count(//quick[. ='yes'])"/> </xsl:template>
</xsl:stylesheet>
Oxygen returns: value is not a node set
Sorry, seems that count(//quick[. = 'yes']) does work.
Many thanks.
dd wrote: Bjoern Hoehrmann wrote:
* dd wrote in comp.text.xml:
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 <xsl:template select="????"> I tried count(//quick/*) >0 * only matches element nodes while "yes" is a text node. You can
count(//quick/text())
But that would also count
<quick> </quick>
So
count(//quick[.="yes"])
might be better.
Tried this also: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:apply-templates select="count(//quick[. ='yes'])"/>
Well you need
<xsl:value-of select="count(//quick[. ='yes'])"/>
if you want to output the value. xsl:apply-templates tries to apply
templates against the select attribute value and that has then indeed to
be a nodeset.
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: anonymous |
last post by:
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...
|
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)...
|
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...
|
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"?>...
|
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...
|
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>...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |