Subject: Re: [xsl] grouping problem From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Fri, 16 Apr 2010 01:32:26 +0200 |
I suspect that I should be using group-adjacent but am I unsure how to go ahead with such grouping in this case.
======8<----------------------------- <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:template match="testbody"> <testbody> <xsl:for-each-group select="*" group-starting-with="p[ @class=( 'bodytext-question', 'bodytext-questionfirst' ) ]"> <xsl:choose> <!-- Don't consider the first group if it starts with something else: --> <xsl:when test="self::p[ @class=( 'bodytext-question', 'bodytext-questionfirst' ) ]"> <xsl:for-each-group select="current-group()" group-adjacent="boolean( self::p[ @class=( 'bodytext-question', 'bodytext-questionfirst', 'bodytext-choice' ) ] )"> <xsl:choose> <xsl:when test="current-grouping-key()"> <xsl:element name="question"> <xsl:apply-templates select="current-group()"/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </testbody> </xsl:template>
<xsl:template match="@* | *"> <xsl:copy> <xsl:apply-templates select="@* | node()" /> </xsl:copy> </xsl:template>
</xsl:stylesheet> ======8<-----------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] grouping problem, Michael Kay | Thread | [xsl] grouping issue (part 2), Terry Ofner |
RE: [xsl] grouping problem, Michael Kay | Date | Re: [xsl] The output of evaluating , C. M. Sperberg-McQue |
Month |