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

Reverse axis, reverse document order, xsl:for-each

Subject: Reverse axis, reverse document order, xsl:for-each
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Thu, 28 Feb 2008 10:28:23 +0100
 Reverse axis
I want to process nodes collected on a reverse axis in reverse document
order (RDO). Using xsl:for-each, it doesn't work. Why is this so? Why
does xsl:for-each obliterate the direction offered by the axis? Why does
it revert reversion?

What precise situation does RDO apply to? Is it only for node test
immediately attached to the axis step?

And, last question, is there a way to have a pointer (xsl:variable) to
nodes in RDO without resorting to copying or reconstructing? (See
example two in the stylesheet below.)

I'm using XSL language version 1.0 with libxslt.

mludwig@forelle:~/xpg/Werkstatt/xsl-rdo > expand -t1 rdo.xml
<Urmel>
 <elm>eins</elm>
 <elm>zwei</elm>
 <elm>drei</elm>
</Urmel>

mludwig@forelle:~/xpg/Werkstatt/xsl-rdo > expand -t1 rdo.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text"/>
 <xsl:template match="/">
  <xsl:variable name="my-node" select=".//elm[ . = 'drei' ]"/>
  <!-- one -->
  <xsl:for-each select="$my-node/preceding-sibling::elm">
   <xsl:value-of select="concat(. , '&#10;')"/>
  </xsl:for-each>
  <!-- two, same thing using a variable -->
  <xsl:variable name="prec" select="$my-node/preceding-sibling::elm"/>
  <xsl:for-each select="$prec">
   <xsl:value-of select="concat(. , '&#10;')"/>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

mludwig@forelle:~/xpg/Werkstatt/xsl-rdo > xsltproc rdo.xsl rdo.xml
eins
zwei
eins
zwei

The output I want and expect is the reverse:
zwei
eins
zwei
eins

Michael

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.