Subject: Re: [xsl] Node set From: YueMa <may@xxxxxxxxxxxxxxxx> Date: Mon, 05 Feb 2001 15:49:11 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Node set, Jeni Tennison | Thread | Re: [xsl] Node set, Jeni Tennison |
RE: [xsl] Problem generating combin, Kane, David | Date | Re: [xsl] CSS and XSLT, again, Michael Beddow |
Month |