xsl-list
[Top] [All Lists]

[xsl] Sum in conjunction with string splitting?

2006-09-08 09:55:52
Posted yesterday, but I isolated the problem significantly =)

The snippet below attempts to split the string 'mileage 6' into
[mileage] and [6] and then store it in $miles (for example).

I am trying to get the SUM of the resulting SPLIT of the nodes that
match 'mileage'.

I am close. Right now I only get one node, not the sum of all matches.

<xsl:variable name="miles">
        <xsl:call-template name="str-split-to-words">
                <xsl:with-param name="pStr"
select="msxsl:node-set($expenses[substring(expense,1,7)='mileage']/expense)"
/>
                <xsl:with-param name="pDelimiters" select="' '" />
                                     <!-- splitting expense at blank spaces -->
        </xsl:call-template>
</xsl:variable>
<xsl:value-of select="msxsl:node-set($miles)/*[2]" /><br />

====

$expenses example:

<Expenses>
   <expense>Mileage 6</expense>
   <expense>cheese</expense> (wouldn't match)
   <expense>Mileage 10</expense>
</Expenses>

====

Desired value of $miles: 16.

Thanks a bunch,

-Steve

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