[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: preceding-sibling after sort gives unexpected resu
Kaine Varley wrote:
I am trying to process a document similar to the one below, using the stylesheet below. My problem is that after I have performed the sort, I appear to get the preceding sibling in the original document order rather than in the newly sorted order.
- Access the previous element by index. You'll need to sort the selected stuff again. This is a sort of brute force approach, use with caution in all cases: <xsl:for-each select="$stuff-to-be-sorted"> <xsl:variable mname="this-index" select="position()"/> <xsl:text>Previous: </xsl:text> <xsl:for-each select="$stuff-to-be-sorted"> <if test="position()=$this-index - 1"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:for-each> - Do some analysis whether you can determine the previous node in the sorted sequence by some other method. - Use an XSLT 2.0 processor. Check the spec for details, specifically the sort() XPath 2.0 function. J.Pietschmann XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|