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

Grouping a sequence of elements in different ways in t

Subject: Grouping a sequence of elements in different ways in the same stylesheet
From: Peter Desjardins <peter.desjardins.us@xxxxxxxxx>
Date: Fri, 21 May 2010 17:09:05 -0400
 Grouping a sequence of elements in different ways in t
Hi.  I'm writing a 2.0 stylesheet to convert flat HTML to a
hierarchically structured XML format such as DocBook or DITA. I'm new
to XSLT.

I need to group the HTML elements into <section> elements according to
heading levels (such as h1, h2, h3). I've got that working using the
group-starting-with attribute of <xsl:for-each-group> thanks to help
from this list.

Now I need to wrap other sequences whenever they come up in the source
document. For example, whenever bulleted paragraph styles occur, I
need to group them in an <itemizedlist> element. I can do this also
with the group-adjacent attribute of <xsl:for-each-group>.

I've gotten stuck trying to group sections and itemized lists at the
same time. I need my stylesheet to pass through the entire sequence of
elements and perform grouping operations as needed. If a bulleted list
occurs at any point, group it. If a h1, h2, or h3 element occurs,
start a new group for a <section> element. I'll also need to handle
other types of wrapping such as for numbered lists.

Can anyone point me to an example of that sort of stylesheet? One that
performs several types of grouping during the same pass over a
sequence of elements? Here's an example of the code I'm using. Both of
the grouping operations will work if I use them alone.

<xsl:template match = "body/div" >
    <xsl:for-each-group select = "current-group()" group-adjacent =
"name()='p' and @class='bulletedlist'">
        <xsl:apply-templates select = "." mode = "itemizedlist" />
    <!-- How do I perform both of these grouping operations at the
same time? -->
    <xsl:for-each-group select = "*" group-starting-with = "p[@class='head1']" >
        <xsl:apply-templates select="." mode="group-level-one"/>

Thanks for your help.


Current Thread


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.
First Name
Last Name
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.