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

Re: Sorting Sibling Nodes !!!

Subject: Re: Sorting Sibling Nodes !!!
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 17 May 2001 10:21:38 +0100
Re:  Sorting Sibling Nodes !!!
Hi Ciaran,

> (NB - I need the output as <template></template> and not
> <template/>).

That's not something that you can control from within a stylesheet. If
you need that specific output structure, then you should probably
write a serialiser that you tack on to whatever processor you're using
to write out the tree in the way that you want it written out.
However, any XML application worth its salt will treat the two
versions in exactly the same way, so it's not clear why you care.

> 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"/> ?.

Yes.  You can get around it by having the do-matching template in the
default mode do nothing:

<xsl:template match="do" />

And then apply templates from within the template-matching template in
'copy' mode:

<xsl:template match="template">
   <xsl:element name="{name()}">
      <xsl:apply-templates select="following-sibling::do"
                           mode="copy" />
   </xsl:element>
</xsl:template>

And add a mode to the do-matching template that you have currently:

<xsl:template match="do" mode="copy">
   <xsl:element name="{name()}">
      <xsl:apply-templates />
   </xsl:element>
</xsl:template>

(Is there any particular reason why you're using <xsl:element
name="{name()}" /> rather than <xsl:copy />?  They do do slightly
different things, so you could feasibly be doing it to get rid of
namespaces that you don't want, though in that case you should use
<xsl:element name="{local-name()}" /> instead.)

I hope that helps,

Jeni

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



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.