xslt: count elements...

R

ralf321

Hello!

i want to count elements in xslt.
All with meta=13 contains a AND meta 14 contains b
but it dont work any Idee why?
Thanks.


i try it with
count(object/node[@meta='27']/data[(@meta='13' and contains(.,'a'))
and (@meta='14' and contains(.,'b'))])

but always its zero.

my xml:

<object>
<node meta="27" >
<data meta="13" >a</data>
<data meta="14" >b</data>
<data meta="15" >c</data>
<data meta="16" >d</data>
</node>

<node meta="27" >
<data meta="13" >a</data>
<data meta="14" >b</data>
<data meta="15" >c</data>
<data meta="16" >d</data>
</node>
<node meta="27" >
<data meta="13" >s</data>
<data meta="14" >b</data>
<data meta="15" >c</data>
<data meta="16" >d</data>
</node>
</object>
 
?

=?ISO-8859-1?Q?Joachim_Wei=DF?=

Hello!

i want to count elements in xslt.
All with meta=13 contains a AND meta 14 contains b


i try it with
count(object/node[@meta='27']/data
you count data????

[(@meta='13' and contains(.,'a'))
with a meta attribute of 13 and containing an 'a'
and (@meta='14' and contains(.,'b'))])
!and! with a meta attribute of 14 and containing an 'b'

your are looking for:
<data meta="13" meta="14">ab</data>

This would help:

<xsl:value-of select="
count(object/node[@meta=27 and ((data[@meta=13] and contains(.,'a')))
and (data[@meta=14] and contains(.,'b'))])" />


HIH

Jo
 
R

ralf321

i want count the 'node' wich have the elements data meta=13 contains a
AND meta 14 contains b
 
R

Richard Tobin

i try it with
count(object/node[@meta='27']/data[(@meta='13' and contains(.,'a'))
and (@meta='14' and contains(.,'b'))])

That counts data elements having a meta attribute of 13 and a meta
attribute of 14. No element has two meta attributes, so you get no
matches.

You want to count nodes:

count(object/node[...])

where the node has a data child with @meta='13' and which contains 'a':

data[@meta='13' and contains(., 'a')]

and similarly

data[@meta='14' and contains(., 'b')]

so put those two conditions in the predicate.

-- Richard
 
R

ralf321

great thanks

count(object/node[@meta='27' and ((data[@meta='13' and contains(.,'a')]
and (data[@meta='14' and contains(.,'b')]) ] )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top