xsl-list
[Top] [All Lists]

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

2012-05-10 12:25:06
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(_at_)CraneSoftwrights(_dot_)com>
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com; xslforum xslforum 
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
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-AllDocuments-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(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>