Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Re: Grouping / Count Issue

From: "Miraodb" <miraodb@----------->
To:
Date: 12/2/2005 9:37:00 AM
Hi,

first of all, thanks all for your quick and great answers !
David's first solution works fine, however the xslt 2 one gives me an error
which i dont understand:
java.lang.RuntimeException: Required type of second operand of '/' is
node(); supplied value has type xs:string

Gabriel's solution is a nice one too...

I indeed use xslt2 and i would love to have it work. any help is much
appreciated.

Just for info, i actually found myself another solution but it's like 3
times slower coz i use two nested for-each which slow down the process a
lot.

Thanks a lot in advance for your help again.

Fabrice

> Grouping / Count Issue
> 23111 by: Miraodb
> 23112 by: David Carlisle
> 23113 by: Gabriel Osorio
> 23114 by: David Carlisle
> David
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:key name="f" match="Field" use="@name"/>
>
> <xsl:template match="/">
> <xsl:text>
> </xsl:text>
>
> <xsl:for-each select="Report/GrandTotal/RecordValues/Record">
>
> <xsl:variable name="v">
> <xsl:for-each  select="FieldValue[key('f',@fieldName)/@dataType='V']">
> <xsl:value-of select="@fieldValue"/>
> </xsl:for-each>
> </xsl:variable>
>
> <xsl:for-each select="FieldValue[key('f',@fieldName)/@dataType='F']">
> <xsl:value-of select="$v"/>
> <xsl:value-of select="substring(key('f',@fieldName)/@title,1,2)"/>
> <xsl:text> </xsl:text>
> <xsl:value-of select="@fieldValue"/>
> <xsl:text>
> </xsl:text>
> </xsl:for-each>
> <xsl:text>
> </xsl:text>
> </xsl:for-each>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
> Date: Thu, 1 Dec 2005 09:55:40 -0500
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> From: "Gabriel Osorio" <gosorio@xxxxxxxxxxx>
> Subject: RE: [xsl] Grouping / Count Issue
> Message-ID: <EXCHANGECndg5oQJgAG000005f4@xxxxxxxxxxxxxxxxxxxx>
>
> This formula:
>
> Put Record fields on a string variable separated by commas.
> Then, with a loop, call recursive template.
> Get first element and the rest.
>
> This example works fine for my own last troubles:
>
> <xsl:template match="Report">
> <xsl:variable name="fieldNames">
>    ,<xsl:for-each select="GrandTotal/RecordValues/Record/FieldValue">
> <xsl:value-of select="@fieldName"/>,
>    </xsl:for-each>x
> </xsl:variable>
>
> <xsl:for-each select="Layout/Field[@dataType = 'F']">
> <xsl:call-template name="split">
> <xsl:with-param name="fields" select="$fieldNames"/>
> </xsl:call-template>
> </xsl:for-each>
>
> <!--Logic for Field[not(@dataType = 'F')]-->
> </xsl:template>
>
> <xsl:template name="split">
>   <xsl:param name="fields"/>
>   <xsl:variable name="head" select="substring-before($fields,',')"/>
>   <xsl:variable name="tail" select="substring-after($fields,',')"/>
>
>   <xsl:if test='$head'>
> ...
>   </xsl:if>
>
>   <xsl:if test='$tail'>
> <xsl:call-template name="split">
> <xsl:with-param name="fields" select="$tail"/>
> </xsl:call-template>
>   </xsl:if>
> </xsl:template>
>
> Gabriel
>
> -----Original Message-----
> From: Miraodb [mailto:miraodb@xxxxxxxxxxx]
> Sent: Thursday, December 01, 2005 8:52 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Grouping / Count Issue
>
> > Grouping / Count Issue
> > 22986 by: Miraodb
> > 22987 by: Gabriel Osorio
>
> > Date: Mon, 28 Nov 2005 11:02:07 -0500
> > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> > From: "Gabriel Osorio" <gosorio@xxxxxxxxxxx>
> > Subject: RE: [xsl] Grouping / Count Issue
> > Message-ID: <EXCHANGEaeJnKWiQsEH000018fd@xxxxxxxxxxxxxxxxxxxx>
> >
> > Maybe with:
> >
> > <!-- F Fields -->
> > <xsl:apply-templates select="Field[@dataType = 'F']" />
> > <!-- other -->
> > <xsl:apply-templates select="Field[not(@dataType = 'F')]" /&gt;
> >


> Date: Thu, 1 Dec 2005 15:04:23 GMT
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> From: David Carlisle <davidc@xxxxxxxxx>
> Subject: Re: [xsl] Grouping / Count Issue
> Message-Id: <200512011504.PAA25360@xxxxxxxxxxxxxxxxx>
>
> or, if you are using xslt2
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:key name="f" match="Field" use="@name"/>
>
> <xsl:template match="/">
>     <xsl:value-of separator=""
>
select="Report/GrandTotal/RecordValues/Record/FieldValue[key('f',@fieldName)
/@dataType='F']/
>                  ('&#10;',
>
../FieldValue[key('f',@fieldName)/@dataType='V']/string(@fieldValue),substri
ng(key('f',@fieldName)/@title,1,2),
>                   ' ',string(@fieldValue))"/>
> </xsl:template>
>
> </xsl:stylesheet>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent