xslt: count elements...

Discussion in 'XML' started by ralf321@gmx.de, Dec 9, 2005.

  1. Guest

    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>
    , Dec 9, 2005
    #1
    1. Advertising

  2. schrieb:
    > 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
    =?ISO-8859-1?Q?Joachim_Wei=DF?=, Dec 9, 2005
    #2
    1. Advertising

  3. Guest

    i want count the 'node' wich have the elements data meta=13 contains a
    AND meta 14 contains b
    , Dec 9, 2005
    #3
  4. In article <>,
    <> wrote:

    >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
    Richard Tobin, Dec 9, 2005
    #4
  5. Guest

    great thanks

    count(object/node[@meta='27' and ((data[@meta='13' and contains(.,'a')]
    and (data[@meta='14' and contains(.,'b')]) ] )
    , Dec 9, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miel Bronneberg

    xslt count error

    Miel Bronneberg, Oct 24, 2003, in forum: XML
    Replies:
    2
    Views:
    1,371
    Miel Bronneberg
    Oct 24, 2003
  2. Marcel Akkerman
    Replies:
    5
    Views:
    850
    Marcel Akkerman
    Feb 22, 2004
  3. Gerald Aichholzer
    Replies:
    2
    Views:
    2,471
    Gerald Aichholzer
    Jun 27, 2006
  4. njsimha
    Replies:
    0
    Views:
    430
    njsimha
    Sep 12, 2008
  5. efelnavarro09
    Replies:
    2
    Views:
    896
    efelnavarro09
    Jan 26, 2011
Loading...

Share This Page