Hi, Andy,
Here's a similar transform, to move a client's custom XML structure to
DocBook:
<xsl:for-each-group select="*" group-starting-with="Heading1">
<section>
<xsl:apply-templates select="current-group()[self::Heading1]" />
<xsl:for-each-group select="current-group() except ."
group-starting-with="Heading2">
<xsl:choose>
<xsl:when test="self::Heading2">
<section>
<xsl:apply-templates select="current-group()[self::Heading2]" />
<xsl:for-each-group select="current-group() except ."
group-starting-with="Heading3">
<xsl:choose>
<xsl:when test="self::Heading3">
<section>
<xsl:apply-templates
select="current-group()[self::Heading3]" />
<xsl:for-each-group select="current-group() except ."
group-starting-with="Heading4">
<xsl:choose>
<xsl:when test="self::Heading4">
<section>
<xsl:apply-templates
select="current-group()[self::Heading4]" />
<xsl:for-each-group select="current-group()
except ." group-starting-with="Heading5">
<xsl:choose>
<xsl:when test="self::Heading5">
<section>
<xsl:apply-templates
select="current-group()[self::*]" />
</section>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="current-group()[self::*]" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</section>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="current-group()[self::*]" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</section>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()[self::*]" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</section>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()[self::*]" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</section>
</xsl:for-each-group>
As you can see, it chews its way through 5 levels of heading to create
nested section elements.Then other templates handle the elements within the
sections.
HTH
Jay Bryant
Bryant Communication Services
----- Original Message -----
From: "Andy Carr1" <CARRA(_at_)uk(_dot_)ibm(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, February 21, 2007 3:05 AM
Subject: [xsl] Re: xsl-list Digest 21 Feb 2007 06:10:00 -0000 Issue 1055
Jay
I have wound up with xsl:for-each-group nested 6 deep within the same
template (to handle the
document's headers) and further uses of xsl:for-each-group in templates
that get called from
there (to handle lists).
Do you have any examples on this as I got in a bit of a muddle when I
tried a few days ago.
Also the link to the implicit wrappers seems to be broken.
http://www.xslt.com/html/xsl-list/2005-08/msg01085.html
Thanks for the help, it's nice to know I was on the right track.
Regards
Andy
Andy Carr
IT Specialist
Tel: Internal - 298037 External - 01252 558037
Mail Point M1C IBM Application Services
Meudon House, Meudon Avenue, Farnborough, GU14 7NB
(Notes) Andy Carr1/UK/IBM(_at_)IBMGB
(Internet)CARRA(_at_)uk(_dot_)ibm(_dot_)com
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--