|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: creating container elements
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








