Andrew,
what warning would you hope to see?
On 04/12/2007, Terry Ofner <tofner@xxxxxxxxxxx> wrote:
> Dear xsl-list,
>
> I am attempting to group the following using XSLT 2.0. Here is a
> snippet of the XML (edited for readability):
>
> <?xml version="1.0"?>
> <Root>
> <State>
> <!--first standard; first lesson-->
> <Standard>
> <SS id="1.4.1">1.4.1 standard text </SS>
> <Lesson>Prefixes and Suffixes</Lesson>
> </Standard>
>
> <!--same standard as first; new lesson-->
> <Standard>
> <SS id="1.4.1">1.4.1 standard text</SS>
> <Lesson>Root Words</Lesson>
> </Standard>
>
> <!--new standard; new lesson-->
> <Standard>
> <SS id="1.4.2">1.4.2 standard text</SS>
> <Lesson>Context Clues</Lesson>
> </Standard>
>
> <!--two standards grouped with one lesson-->
> <Standard>
> <SS id="1.4.5">1.4.5 standard text/SS>
> <SS id="1.4.6">1.4.6 standard text</SS>
> <Lesson>Synonyms</Lesson>
> </Standard>
> . . .
> </State>
> </Root>
>
> Here is what I am seeking:
>
> <!--Lessons grouped after common standard-->
>
> <Standard>
> <SS id="1.4.1">1.4.1 standard text </SS>
> <Lesson>Prefixes and Suffixes</Lesson>
> <Lesson>Root Words</Lesson>
> </Standard>
>
> . . .
>
> <!--grouped standards separated-->
>
> <Standard>
> <SS id="1.4.5">1.4.5 standard text </SS>
> <Lesson>Synonyms</Lesson>
> </Standard>
> <Standard>
> <SS id="1.4.6">1.4.6 new standard grouped with preceeding
> sibling</SS>
> <Lesson>Synonyms</Lesson>
> </Standard>
>
> So far I have been able to group the <SS> elements using for-each-group:
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="no"/>
>
> <xsl:template match="State">
> <xsl:for-each-group select="Standard/SS" group-by="@id">
> <xsl:for-each select="current-group()"/>
> <xsl:copy-of select="."/><xsl:text> </xsl:text>
> </xsl:for-each-group>
> </xsl:template>
> </xsl:stylesheet>
>
>
> When I try to work in the <Lesson> elements, I get the entire
> standards listing.
> I have also wondered if I need to first separate the grouped standards.
>
> Any help would be appreciated.
>
> Terry
|