Subject: [xsl] group-adjacent problem From: Ruud Grosmann <r.grosmann@xxxxxx> Date: Tue, 16 Dec 2008 13:44:06 +0100 |
<doc> <chapter> <sect> <p>p1</p> <p>p2</p> </sect> <sect> <p>p3</p> </sect> <image/> <sect> <p>p4</p> </sect> </chapter> </doc>
<doc> <chapter> <sections> <p>p1</p> <p>p2</p> <p>p3</p> </sections> <image/> <sections> <p>p4</p> </sections> </chapter> </doc>
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<xsl:template match="/"> <xsl:apply-templates/> </xsl:template>
<xsl:template match='*[sect]'> <xsl:for-each-group select="*" group-adjacent="name()" > <xsl:for-each select="current-group()"> <xsl:choose> <xsl:when test="current-grouping-key() = 'sect'"> <sections> <xsl:apply-templates select='.' mode='sect'/> </sections> </xsl:when> <xsl:otherwise> <xsl:apply-templates select='.'/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:for-each-group> </xsl:template>
<xsl:template match='sect' mode='sect'> <xsl:apply-templates/> </xsl:template>
<xsl:template match='*'> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates /> </xsl:copy> </xsl:template>
<?xml version="1.0" encoding="utf-8"?> <doc> <sections> <p>p1</p> <p>p2</p> </sections> <sections> <p>p3</p> </sections> <image/> <sections> <p>p4</p> </sections> </doc>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] ooxml grouping, Andreas Peter | Thread | Re: [xsl] group-adjacent problem, David Carlisle |
RE: [xsl] use transformator to add , henry human | Date | Re: [xsl] group-adjacent problem, David Carlisle |
Month |