xsl-list
[Top] [All Lists]

[xsl] Nested grouping using group-starting-with - brief code review?

2010-05-17 09:05:00
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

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>