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
| 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)
|
|