Re: [xsl] How to count elments which have specific sub element

Subject: Re: [xsl] How to count elments which have specific sub element
From: henry human <henry_human@xxxxxxxx>
Date: Thu, 10 May 2012 17:24:53 +0100 (BST)
Thank you guyes. But I recognized that the count of elements does not help!
Because I still do not know which ot the counted Taxtotals has the specific
element I am looking for!
(in the sample the specific element was Amount)

It
will helpe me if you read my secound posting titeld 'Get the first Array
elment'

Thank you

----- Urspr|ngliche Message -----
Von: G. Ken Holman
<gkholman@xxxxxxxxxxxxxxxxxxxx>
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xslforum
xslforum <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
CC: 
Gesendet: 17:57 Donnerstag,
10.Mai 2012
Betreff: Re: [xsl] How to count elments which have specific sub
element

At 2012-05-10 15:52 +0100, henry human wrote:
> Hi
> <elements>
>
....
>  <TaxTotal>
>  <otherAmount>22.00</otherAmount>
>  </TaxTotal>
> 
.......
>  <TaxTotal>
>  <otherAmount>90.00</otherAmount>
>  </TaxTotal>
> 
<TaxTotal>
>      .....
>  <Amount>44.00</Amount>
>  </TaxSubtotal>
> 
</TaxTotal>
>  <TaxTotal>
>  .....
>  <Amount>10.00</Amount>
>  </TaxSubtotal>
>  </TaxTotal>
>  ......
> </elements>
> ---------------------
> How can I
count ONLY the  TaxTotal elements which HAS Amount
> I tried
Count(TaxTotal/cbc:RoundingAmount) but it is wrong as expctted!
> ??

As
Dmitry says, it is difficult to guess what you want because your question is
unclear.

But I recognize your use of elements and namespace prefixes as
likely being OASIS UBL.

Looking at the TaxTotal aggregate (note the page is
very long and takes a while to load):
http://docs.oasis-open.org/ubl/prd2-UBL-2.1/mod/summary/reports/UBL-AllDocume
nts-2.1.html#t-CommonLibrary-1820

... I see that <cbc:TaxAmount> is a
mandatory child of <cac:TaxTotal>.  Therefore you know the count of those
children is the same as the count of the parents.

But you cite
<cbc:RoundingAmount> in your question.  Are you perhaps looking for the count
of those <cac:TaxTotal> elements that have the optional <cbc:RoundingAmount>
child?  That would be:

  count(cac:TaxTotal[cbc:RoundingAmount])

... which
actually would be the same as the count of the rounding amounts:

 
count(cac:TaxTotal/cbc:RoundingAmount)

I hope this helps ... but it is only a
guess.

. . . . . . . . . . Ken


--
Public XSLT, XSL-FO, UBL and code list
classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and
instructor-led training
Free 5-hour lecture:
http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.       
    http://www.CraneSoftwrights.com/s/
G. Ken Holman                 
mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile:
https://plus.google.com/116832879756988317389/about
Legal business
disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread