[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Nested grouping using group-starting-with - brief

Subject: Re: 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
Re:  Nested grouping using group-starting-with - brief
Dear Peter,

For just 2 levels of nested grouping, your approach seems reasonable. A more generic approach using recursive grouping (and permitting gaps in hierarchy, for example h3 following h1) may be found here:
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201004/msg00124.html
Since this was meant for ToC generation, you'll have to replace all the <ul> stuff with <section> as appropriate, and remove the comment on the line below "<!-- no output for non-headings, as we are creating the ToC: -->".


Hope this helps.

Gerrit


On 17.05.2010 16:04, Peter Desjardins wrote:
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.