Subject: [xsl] Trouble grouping with for-each-group and sort From: <mlcook@xxxxxxxxxx> Date: Wed, 17 Mar 2010 13:58:20 -0400 |
I have a collection of data that I'm trying to sort, but am having difficulty with the for-each-group and sort operations. The data is a series of elements of the form: <DataItem xmlns="myns"> <A>2</A> <B>1</B> <C>6</C> <D>4</D> <E>740</E> <F>99</F> <G> <sub1>202</sub1> <sub2>0</sub2> <sub3> <inner>1.1</inner> </sub3> </G> <H> <sub1>202</sub1> <sub2>262</sub2> <sub3> <inner>1.15</inner> </sub3> </H> </DataItem> where <G> and <H> have the same kind of data with the same sub-element names. The variable $list contains lots of DataItem elements. Here's my current grouping and sorting attempt (from a larger transformation): <xsl:for-each-group select="$list/myns:DataItem" group-by="myns:A"> <xsl:sort select="current-grouping-key()" data-type="number"/> <xsl:for-each-group select="current-group()" group-by="myns:B"> <xsl:sort select="current-grouping-key()" data-type="number"/> <xsl:for-each-group select="current-group()" group-by="myns:C"> <xsl:sort select="current-grouping-key()" data-type="number"/> <xsl:for-each-group select="current-group()" group-by="myns:D"> <xsl:sort select="current-grouping-key()"/> <xsl:for-each-group select="current-group()" group-by="myns:E"> <xsl:sort select="current-grouping-key()" data-type="number"/> <xsl:sort select="myns:G/myns:sub3/myns:inner" data-type="number"/> <xsl:call-template name="process-data" > <xsl:with-param name="data-set" select="current-group()"/> </xsl:call-template> </xsl:for-each-group> </xsl:for-each-group> </xsl:for-each-group> </xsl:for-each-group> </xsl:for-each-group> When I run the transformation, all the groupings from the for-each-group operations work fine. but the data is not sorted (it appears) at the innermost grouping according to the value of "myns:G/myns:sub3/myns:inner" when the "process-data" template is invoked. All the other data is grouped and sorted fine, except for the last sort on "inner". Any ideas why the last sort doesn't appear to work? Does a data-type of "number" for sorting correctly process numbers with decimal points? Am I using the wrong select on the parameter for process-data? Is current-group() at that point not the sorted data that I think it should be? Is there a limit on nested for-each-group operations? I'm using Oxygen 10.3 with Saxon SA 9.1.0.7. Thanks, Mike This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Display the number of, David Carlisle | Thread | RE: [xsl] Trouble grouping with for, Michael Kay |
Re: [xsl] Re: Display the number of, David Carlisle | Date | RE: [xsl] Trouble grouping with for, Michael Kay |
Month |