This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Resent: Sorting Sibling Nodes !!!
- To: "Xsl-List" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Resent: Sorting Sibling Nodes !!!
- From: "Ciaran Byrne" <ciaran dot byrne at 3tl dot com>
- Date: Thu, 17 May 2001 10:13:23 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi all,
I have some content of the form..
<template/><do type="accept"><go href="foo"/></do>
what I want is the following...
if 'do' is a sibling of template(as above) then place 'do'
inside template ie.
<template><do type="accept"><go href="foo"/></do></template>
otherwise leave 'template' as is..
<template></template>.
(NB - I need the output as <template></template> and not <template/>).
I've tried this with the XSL below(Snippet!), However I'm getting duplicate
outputs. Is this because the 'do' gets matched once as a sibling and
a second time when I have <xsl:apply-templates
select="following-sibling::do"/> ?.
In any matter, could someone suggest some ideas ;o)
<!-- ELEMENT do -->
<xsl:template match = "do">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- ELEMENT template -->
<xsl:template match="template">
<xsl:choose>
<xsl:when test="following-sibling::do">
<xsl:element name="{name()}">
<xsl:apply-templates select="following-sibling::do"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Thanks for the help,
Ciaran.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list