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

Re: The order of selected nodes in a select pattern with OrE

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
apply templates select order
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

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.