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

Re: Node set

Subject: Re: Node set
From: YueMa <may@xxxxxxxxxxxxxxxx>
Date: Mon, 05 Feb 2001 15:49:11 -0500
xsl order node set
Thanks for the solution, Jeni!
The reason I asked about ordered node set was that I have to group those
title elements in the sample XML...
(Now I'm clearly understand thata node set is not ordered.... ;-))
Say I may have 8 or 10 title elements and finally, I'm going to display
them within an HTML table, 4 on the left
and 4 on the right column....without specific ordering, it's easy.
And the bad news is the rule used to grouping them is "logic", so looks
like nothing I can follow.... and as I
said, the total number of title element is not guaranteed, if 4th element
was missing, I have to move the 5th
element to the left column!  ;(
Right now I just can not find a solution  for that, maybe this case is not
good for XSL, I think I'm going to write
a program to handle that......


Yue


Jeni Tennison wrote:

> Hi YueMa,
>
> > How can I create a node set with specific order other than document
> > order?
>
> As David "pure mathematician" Carlisle says, node sets aren't ordered,
> so you can't create one with an order, but you can choose what order
> to process them in.
>
> > How about if I want to  display like:
> > title2
> > title4
> > title1
> > title3
>
> Then apply templates (or use xsl:for-each) in that order:
>
>   <xsl:apply-templates select="title2" />
>   <xsl:apply-templates select="title4" />
>   <xsl:apply-templates select="title1" />
>   <xsl:apply-templates select="title3" />
>
> This hardcodes into the stylesheet the order in which they're
> processed in a certain context.  You could select the order in any
> number of ways.
>
> > the order is not fixed and may changd everytime, and even the number
> > of titles are not guaranteed, maybe 4, maybe 3, etc.
>
> There must be some underlying way of choosing which order you want
> them in?  What is it?
>
> > What I wanted to do is to create a node set with the particular
> > order and then I can process elements just by using <xsl:for-each>,
> > is that possible in XSL?
>
> Not really (although you could feasibly create a result tree fragment
> variable and then iterate over that with xsl:for-each having turned it
> into a node set with an extension function).
>
> If you apply templates to the nodes you want in order, as outlined
> above, then you can have a template that matches any of them and that
> contains whatever you want to put in the body of the xsl:for-each:
>
> <xsl:template match="title1 | title2 | title3 | title4">
>    ... body of the xsl:for-each ...
> </xsl:template>
>
> I hope that helps,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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


Current Thread
  • Node set
    • YueMa - Mon, 5 Feb 2001 11:45:24 -0500 (EST)
      • David Carlisle - Mon, 5 Feb 2001 12:05:10 -0500 (EST)
      • Jeni Tennison - Mon, 5 Feb 2001 13:50:45 -0500 (EST)
        • YueMa - Mon, 5 Feb 2001 15:57:30 -0500 (EST) <=

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.