[Home] [By Thread] [By Date] [Recent Entries]
Dimitre,
Incredibly helpful .txt file on the issue, but I seem to be misapplying it. Do you see any obvious errors? I don't get the underlying logic, so it could be that my use of $expense instead of a source doc is my problem. Less likely is the fact that I'm using fxsl-MS. <xsl:call-template name="transform-and-sum">
<xsl:with-param name="pFuncTransform"
select="document('')/*/func-transform:*[1]"/>
<xsl:with-param name="pList"
select="$expenses[substring(expense,1,7)='mileage']/expense"/>
</xsl:call-template><xsl:template match="func-transform:*"> <xsl:param name="arg" select="0"/> <xsl:value-of select="$arg" /> <!-- This isn't printing anything --> <xsl:value-of select="substring-after($arg, 'mileage')"/> </xsl:template> $expense does indeed contain something like: <Expenses> <expense>mileage 50</expense> <expense>mileage 20</expense> <expense>mileage 30</expense> </Expense> On 9/8/06, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote: On 9/8/06, Steve <subsume@xxxxxxxxx> wrote: > 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.
|

Cart



