xsl-list
[Top] [All Lists]

RE: [xsl] get the sum of a sequence of numbers

2006-05-03 15:34:15
I'm sorry, I can see that you're quoting an answer that I gave in response
to a message of yours, but I don't recall enough of the context to help you
further. Start again with a new question. The usual things: what's your
input, what's your desired output, how are you trying to solve the problem,
where are you getting stuck.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Karen McAdams [mailto:kemcadams(_at_)yahoo(_dot_)com] 
Sent: 03 May 2006 23:09
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] get the sum of a sequence of numbers

         > That does not seem to work in this situation.

Gives the wrong answer? Gives an error message? Catches fire? 
It's a lot easier to diagnose problems when you know what the 
symptoms are.
========
I concatenates the values in the node and displays them as i 
reported in the first email.



        <xsl:variable name="mbt" select="sum(for $n in
number($mb) return number($n))"/>

number($mb) is going to produce a single number as its 
result. So this is the same as select="sum(number($mb))" 
which is the same as select="number($mb)". I don't know what 
$mb is, but if it's a sequence of strings that can be 
converted to numbers then you want

        <xsl:variable name="mbt" select="sum(for $n in $mb return
number($n))"/>

that is, you want to convert the strings to numbers individually.

However, $mb isn't a sequence of strings, because you declared it as:

      <xsl:variable name="mb">
           <xsl:apply-templates mode="mb"/>
       </xsl:variable>  

which means $mb is actually a single document node; so the 
"for" expression isn't going to do anything useful. I can't 
tell how to correct this without knowing what's coming back 
from the apply-templates.
=====
What's coming back is a document node that contains the word 
count for each child element that contains a language attribute.

What i need cumulative count of the total words of the child 
elements that contain a language attribute. 

The other solution that was recommended was to copy these 
child elements into a document node and count the words in 
this new document node.

Im just not sure what the best technique to use to utilize 
the benefits of xslt 2.0 to accomplish this count-

Karen McAdams





--~------------------------------------------------------------------
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>