|
Subject: Re: The order of selected nodes in a select pattern with OrExpressions? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 24 Jan 1999 21:01:44 -0800 |
At 99/01/24 15:52 -0500, Tyler Baker wrote:
>One thing that does not seem to be clear in the XSL in the XSL draft is
>in what order the nodes should be selected in a select expression with
>or expressions present.
According to production [1]:
A select pattern must match the production for SelectExpr; it returns the
list of nodes that results from evaluating the SelectExpr with the current
node as context; the nodes are in the list are in document order.
However the select expression is constructed the expected result appears to
me to be explicit and unambiguous.
I don't see any constraints, nor would I want any. Consider your example,
if you had a mixture of multiple instantiations of the three elements <b1>,
<b2>, <b3>:
<b1> <b3> <b2> <b3> <b1> <b3> <b2>
... and you wanted to interlink them as they arrived (as in a slide show),
you need them to arrive in document order.
>What if I have a template:
>
><xsl:template match=a>
> <xsl:apply-templates select="b3 | b2 | b1">
></xsl:template>
>
>Should the output text be: cba, or should the output text be: abc.
It should be "abc".
If you wanted it to be cba, then you would do:
<xsl:template match="a">
<xsl:apply-templates select="b3"/>
<xsl:apply-templates select="b2"/>
<xsl:apply-templates select="b1"/>
</xsl:template>
(setting aside issues of preserving the whitespace ... but I hope you can
see what I mean).
A full example is below ... I hope it helps.
......... Ken
T:\FTEMP>type test.xml
<?xml version="1.0"?>
<a>
<b1>
a
</b1>
<b2>
b
</b2>
<b3>
c
</b3>
</a>
T:\FTEMP>type test.xsl
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="a">
<xsl:text>
Document Order:</xsl:text>
<xsl:apply-templates select="b3 | b2 | b1"/>
<xsl:text>
Forced Order:</xsl:text>
<xsl:apply-templates select="b3"/>
<xsl:apply-templates select="b2"/>
<xsl:apply-templates select="b1"/>
</xsl:template>
</xsl:stylesheet>
T:\FTEMP>call xsl test.xml test.xsl test.out
T:\FTEMP>type test.out
Document Order:
a
b
c
Forced Order:
c
b
a
T:\FTEMP>
--
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, V: +1(613)489-0999
Kars, Ontario CANADA K0A-2E0 F: +1(613)489-0995
Training: http://www.CraneSoftwrights.com/s/schedule.htm
Resources: http://www.CraneSoftwrights.com/s/resources.htm
Shareware: http://www.CraneSoftwrights.com/s/shareware.htm
Next XSL Training: X-Tech:1999-03-07 WWW8:1999-05-11
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| The order of selected nodes in a se, Tyler Baker | Thread | RE: The order of selected nodes in , David Schach |
| RE: mixed-content values, David Schach | Date | whitespace, Mattias Konradsson |
| Month |