Subject: [xsl] two-level grouping xslt 2.0 From: Terry Ofner <tofner@xxxxxxxxxxx> Date: Thu, 28 Feb 2008 10:24:13 -0500 |
Input: <book> <bodymatter> <story> <cluster_num>Cluster ONE</cluster_num> <cluster_head>What Influences a Decision?</cluster_head> <thinking_skill>Thinking Skill analyzing</thinking_skill> </story> <story> <pagenum>13</pagenum> </story> <imggroup> <img src="DecisionsDecisions3-web-images/Field%20boy% 20final_fmt.jpeg" alt="missing image file"/> <prodnote/></imggroup> <story> <pagenum>14</pagenum> </story> <story> <story-title>Playing God</story-title> <author>Ouida Sebestyen</author> <p class="initial-paragraph">He was ...</p> <p>So he wasnt going to get away without saying good-bye after all...</p> <!--multiple story, image, and page elements edited out-->
<story> <story-title>TLA</story-title> <author>Jane McFann</author> <p class="initial-paragraph">I trudged down the hallway of ...</p> <p ....</p> <!--etc-->
<story> <cluster_num>Cluster TWO</cluster_num> <cluster_head>Good Decision or Bad Decision?</cluster_head> <thinking_skill>Thinking Skill evaluating</thinking_skill> </story> <story> <pagenum>51</pagenum> </story> <imggroup> <img src="DecisionsDecisions3-web-images/school%20final_fmt.jpeg" alt="missing image file"/> <prodnote/></imggroup> <story> <pagenum>52</pagenum> </story> <story> <story-title>A Kind of Murder</story-title> <author>Hugh Pentecost</author> <p class="initial-paragraph">...</p> </bodymatter> </book>
I would like to group each <cluster_num> inside <level1> elements and <story-title> inside <level2> elements
<xsl:template match="bodymatter"> <bodymatter> <xsl:for-each-group select="*" group-starting-with="story [child::cluster_num]"> <!--for some reason "story/cluster_num" does not catch it--> <level1 class="unit"> <xsl:attribute name="unitnum"><xsl:value-of select="position()"/></ xsl:attribute><xsl:text> </xsl:text> <xsl:for-each-group select="current-group()/*" group-starting- with="story[child::story-title]"> <level2 class="selection"> <xsl:apply-templates select="current-group()"/> </level2> </xsl:for-each-group> <xsl:apply-templates select="current-group()"/> </level1><xsl:text> </xsl:text> </xsl:for-each-group> </bodymatter> </xsl:template>
<bodymatter> <level1 class="unit" unitnum="1"> <level2 class="selection"> <cluster_num>Cluster ONE</cluster_num> <cluster_head>What Influences a Decision?</cluster_head> <thinking_skill>Thinking Skill analyzing</thinking_skill>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Including some records and ex, Lewis, Russell | Thread | Re: [xsl] two-level grouping xslt 2, Martin Honnen |
Re: [xsl] Converting from xml to x, Martin Honnen | Date | Re: [xsl] two-level grouping xslt 2, Martin Honnen |
Month |