This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Counting only some children of a node
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Counting only some children of a node
- From: Christian Cäsar <caesar at mpdigital dot de>
- Date: Thu, 23 Aug 2001 12:58:46 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello list,
consider this XML source:
<somenode>
<Tabelle>
<Spalte>
<Text>
<Neutral>sometext</Neutral>
</Text>
</Spalte>
<Spalte>
<Text>
<Neutral>sometext</Neutral>
</Text>
</Spalte>
<Spalte>
<Text/>
</Spalte>
</Tabelle>
</somenode>
Some 'Text' Elements may have a child and values, others don't. I want
to count the number of 'Spalte' Elements that have 'Text' elements with
a child. The actual XML has more 'Spalte' elements.
I tried
count(descendant::Tabelle/Spalte[/Text/*]) and
count(descendant::Tabellenheader/Spalte[/Text/text()])
but that was (obviously) wrong (I got 0), as is
count(descendant::Tabelle/Spalte)
that got me (number of 'Spalte' Elements). I know I must be
quite close to the solution, but I seem not to be able to see it.
If it is important: I am using Xalan.
Greetings,
Christian Caesar
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list