|
Subject: [xsl] Nested grouping using group-starting-with - brief code review? From: Peter Desjardins <peter.desjardins.us@xxxxxxxxx> Date: Mon, 17 May 2010 10:04:36 -0400 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| re: [xsl] What is the equivalent fo, Vladimir Nesterovsky | Thread | Re: [xsl] Nested grouping using gro, Imsieke, Gerrit, le- |
| Re: [xsl] .NET 4.0 XslCompiledTrans, Max Toro | Date | Re: [xsl] Nested grouping using gro, Imsieke, Gerrit, le- |
| Month |