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

RE: creating container elements

Subject: RE: creating container elements
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 6 Apr 2004 15:29:30 +0300
following sibling container
Hi,

> Given an input document containing amongst other things a 
> recurring element I 
> would like to create a container element in the output 
> document. To my mind 
> this was a case of output an opening container tag prior to the first 
> occurrent of the recurrent element and a closing tag after the last 
> occurrence.
See <http://jenitennison.com/xslt/grouping/>.

You want something like

  <xsl:template match="bar[not(preceding-sibling::*[1][self::bar])]">
    <container>
      <xsl:apply-templates select="." mode="walk"/>
    </container>
  </xsl:template>
  <xsl:template match="bar" />
  <xsl:template match="bar" mode="walk">
    <foobar>
      <xsl:copy-of select="@id"/>
      <xsl:apply-templates/>
    </foobar>
    <xsl:apply-templates select="following-sibling::*[1][self::bar]" mode="walk"/>
  </xsl:template>

For bar in mixed content you need to tweak the expressions and patterns.

Cheers,

Jarno

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.