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

RE: Sibling sort order

Subject: RE: Sibling sort order
From: Richard Bell <RichardBell@xxxxxxxxxxx>
Date: Mon, 3 Apr 2000 13:52:24 +0100
xsl 2 sort sibling variable
David, thanks for your help so far. Based on your information and the
subsequent exchange I think I understand the issue. I certainly understand
it better. If you use a select attribute to obtain a node list,  the
variable element will contain a node list and you can query the path of this
node list using /, // and []. If you do not use a select statement and
instead copy the contents of a node list in the content of the variable, you
obtain a result tree fragment which does not support path based queries.

Therefore, in order to sort the content of the variable, you cannot use a
select statement. Sadly, for my puposes this does not help. The method
behind my madness was yet another grouping methodology. I had intended to
use the relationship between the siblings to determine when the group
field(s) had changed enabling me to process group header(s)/footer(s) etc...
However, in order to do this I need to be able to reference the siblings in
sorted order and I cannot do this unless I use a select statement. It seems
that my only recourse is to use a 2 stage method and transform the data
first into a ordered list before transforming into the output. The example
below illustrates where I am on this one. 

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
    
<xsl:template match="/">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="root">  

 <xsl:variable name="x" select="*"/>

 <xsl:variable name="y">
  <xsl:for-each select="*">
    <xsl:sort select="attribute::f1"/>
    <xsl:copy-of select="."/>
  </xsl:for-each>
 </xsl:variable>
 
 <xsl:apply-templates select="$x"/>
 <xsl:apply-templates select="$y"/>
 
</xsl:template>
 
<xsl:template match="row">
 <xsl:variable name="pos" select="position()-1"/>
 <div>
 <xsl:value-of select="attribute::f1"/>
 <xsl:value-of select="parent::*/*[position()=$pos]/attribute::f1"/> 
 </div>
</xsl:template>

</xsl:stylesheet>

<root>
 <row f1="c"/> 
 <row f1="b"/>
 <row f1="a"/> 
</root>


 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.