Subject: Re: [xsl] Nested grouping using group-starting-with - brief code review? From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Mon, 17 May 2010 16:26:50 +0200 |
Hi.
I'm writing a 2.0 stylesheet to wrap sections of an HTML document in <section> elements. This is part of a conversion to an XML doc format such as DocBook or DITA. I'm very new to XSLT. My processor is Saxon HE 9.2.1.1.
Based on a technique I was given in the following post, I've nested grouping levels to handle h1, h2, and h3 elements.
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201005/msg00105.html
For each heading level except the lowest (h3 in my case) I have included another<xsl:for-each-group> element inside the<section> element in the template. This gives the output I was hoping for.
<xsl:template match="h1" mode="group-level-one"> <xsl:element name = "section"> <xsl:for-each-group select = "current-group()" group-starting-with = "h2"> <xsl:apply-templates select="." mode="group-level-two"/> </xsl:for-each-group> </xsl:element> </xsl:template>
Is this a reasonable way to handle nested grouping? I would appreciate any suggestions for improvment.
Here are my full stylesheet, source, and output.
https://sites.google.com/site/filessharedbypeter/Home/wrap-doc-sections.xsl https://sites.google.com/site/filessharedbypeter/Home/source.xml https://sites.google.com/site/filessharedbypeter/Home/output.xml
Thanks for your help.
Peter
-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Nested grouping using group-s, Peter Desjardins | Thread | [xsl] Moving or removing a period, Flanders, Charles E |
[xsl] Nested grouping using group-s, Peter Desjardins | Date | Re: [xsl] border around a long text, Red Light |
Month |