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

Re: Grouping Adjacent Elements in XSLT 1.0 and Duplica

Subject: Re: Grouping Adjacent Elements in XSLT 1.0 and Duplicates
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 20 Oct 2004 22:07:15 +0100
grouping adjacent elements using xslt
Hi Joe,

> It seems to be a recursion problem but i would appreciate any help I
> could get. Thanks.

The problem is that in the calling template, you're applying templates
to all the <ol_li> elements (in no mode). The first list is being
generated due to templates being applied to the first <ol_li> element,
the second because of templates being applied to the second <ol_li>
element and so on.

To use the kind of recursion that you're using to construct the lists,
you need to just apply templates to the first <ol_li> in each list. So
in the calling template, you need something like:

  <xsl:apply-templates
    select="para |
            ol_li[not(preceding-sibling::*[1][self::ol_li])]" />

Alternatively, you could do the whole thing using step-by-step
recursion, in which case you need to just apply templates to the first
of the <para> or <ol_li> elements:

  <xsl:apply-templates select="*[1]" />

but build in recursion within the <para> template as well:

<xsl:template match="para">
  <p><xsl:apply-templates /></p>
  <xsl:apply-templates select="following-sibling::*[1]" />
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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.