|
Subject: Re: [xsl] XSL Variable not getting set From: mIchael wolff <wolffmart@xxxxxxxxx> Date: Wed, 14 Mar 2007 08:26:16 -0700 (PDT) |
This works great!:
<xsl:for-each select="1 to 12">
<xsl:variable name="p" select="."/>
<xsl:value-of select="if ($cg[@month=$p])
then
$cg[@month=$p]/@cost else 0"/>
<xsl:if
test="position()!=last()">,</xsl:if>
</xsl:for-each>
I had no idea you could loop that way with XSL.
Obviously, I'm a newbie at this and am still learning
a lot.
Thanks to everyone for their help. I really
appreciate it.
-Mike
--- George Cristian Bina <george@xxxxxxxxxxxxx> wrote:
> Check out the following stylesheet:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:niku="http://www.niku.com/xog/Query">
> <xsl:output method="text"/>
> <xsl:template match="/">
> Got: <xsl:apply-templates />
> Expected:
>
>
2007,0017016990001001703914F537,2970.0,3505.0,0,0,0,123.0,0,0,0,0,0,0
> </xsl:template>
>
> <xsl:template
> match="niku:QueryResult/niku:Records">
> <xsl:for-each-group select="niku:Record"
> group-by="concat(@fiscalyear,@gl)">
> <xsl:variable name="cg"
> select="current-group()"/>
> <xsl:if test="@fiscalyear != 'null'">
> <xsl:value-of select="@fiscalyear"/>
> <xsl:text>,</xsl:text>
> <xsl:value-of select="@gl"/>
> <xsl:text>,</xsl:text>
> <xsl:for-each select="1 to 12">
> <xsl:variable name="p" select="."/>
> <xsl:value-of select="if
> ($cg[@month=$p]) then
> $cg[@month=$p]/@cost else 0"/>
> <xsl:if
> test="position()!=last()">,</xsl:if>
> </xsl:for-each>
> </xsl:if>
> </xsl:for-each-group>
> </xsl:template>
> </xsl:stylesheet>
>
> Regards,
> George
>
---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT
> Editor/Debugger
> http://www.oxygenxml.com
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSL Variable not getting , George Cristian Bina | Thread | Re: [xsl] XSL Variable not getting , Abel Braaksma |
| [xsl] multiple level grouping in 2., Goldrick, Jim | Date | Re: [xsl] XSL Variable not getting , Abel Braaksma |
| Month |