This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Sibling sort order


Does anyone know how to select the previous/next sibling while maintaining
the sort order of the current context using Microsoft's XSLT March preview?
The only mechanism I can find to refer to the siblings of the context node
is to use the parent axis (parent::) but any sort order which is being
applied in the context of the current node is lost and the node order
reverts to the order in the original document. Example below. Tks.

<root>
 <row f1="f" f2="1"/>
 <row f1="e" f2="2"/>
 <row f1="d" f2="3"/>
 <row f1="c" f2="4"/>
 <row f1="b" f2="5"/>
 <row f1="a" f2="6"/> 
</root>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 <xsl:template match="/">
  <xsl:apply-templates select="*">
  </xsl:apply-templates>
 </xsl:template>
 <xsl:template match="root">
  <xsl:apply-templates select="*">
   <xsl:sort select="@f1"/>
  </xsl:apply-templates>
 </xsl:template>
 <xsl:template match="row">
  <div>
   <xsl:value-of select="@f1"/>
   <xsl:variable name="pos" select="position()-1"/>
   <xsl:value-of select="parent::*/*[position()=$pos]/attribute::f1"/>   
  </div>
 </xsl:template>
</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]