xsl-list
[Top] [All Lists]

[xsl] Trouble grouping with for-each-group and sort

2010-03-17 13:00:40
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.



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

<Prev in Thread] Current Thread [Next in Thread>