xsl-list
[Top] [All Lists]

Re: [xsl] Document reordering after applying path expression

2015-06-30 14:41:12
http://www.w3.org/TR/xpath20/#dt-path-expression

Each operation E1/E2 is evaluated as follows: Expression E1 is
evaluated, and if the result is not a (possibly empty) sequence of
nodes, a type error is raised [err:XPTY0019]. Each node resulting from
the evaluation of E1 then serves in turn to provide an inner focus for
an evaluation of E2, as described in 2.1.2 Dynamic Context. The
sequences resulting from all the evaluations of E2 are combined as follows:

If every evaluation of E2 returns a (possibly empty) sequence of nodes,
these sequences are combined, and duplicate nodes are eliminated based
on node identity. The resulting node sequence is returned in document order.


On 30.06.2015 21:20, Max Toro maxtoroq(_at_)gmail(_dot_)com wrote:
The following stylesheet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" exclude-result-prefixes="#all"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:xs="http://www.w3.org/2001/XMLSchema";>

   <xsl:output method="xml" indent="yes"/>

   <xsl:template name="main">

      <xsl:variable name="a">
         <a/>
      </xsl:variable>

      <xsl:variable name="b">
         <b/>
      </xsl:variable>

      <for-each1>
         <xsl:for-each select="reverse(($a, $b))">
            <xsl:copy-of select="."/>
         </xsl:for-each>
      </for-each1>

      <for-each2>
         <xsl:for-each select="reverse(($a, $b))/*">
            <xsl:copy-of select="."/>
         </xsl:for-each>
      </for-each2>

   </xsl:template>

</xsl:stylesheet>

Outputs:

<?xml version="1.0" encoding="UTF-8"?>
<for-each1>
   <b/>
   <a/>
</for-each1>
<for-each2>
   <a/>
   <b/>
</for-each2>

Why is the sequence reordered after applying a path expression?
Is this conformant with the standard? If yes, what section talks about it?

I'm using Saxon 9.6.0.6.

Original post: http://stackoverflow.com/questions/31126950

--
Max Toro



-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [xsl] Document reordering after applying path expression, Imsieke, Gerrit, le-tex gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de <=