|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: muliple level sorting using xsl:sort
Hi,
Tempore 11:19:01, die 09/05/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Aravind J <aravindjp@xxxxxxxxx>: when i tried to sort the data using <xsl:for-each select="Part"> <xsl:sort data-type="number" select="descendant-or-self::code/name"/> it is doing e first level sorting correctly, ie data is sorted in 1,2,5 order (code/name) . but sub parts of <part> 5 ie 5-3 and 5-4 are not getting sorted , similarly for children of 5-4 also.
"substring(code/name,string-length(ancestor::Part[1]/code/name) + 1 + boolean(ancestor::Part))" e.g. this stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="AAAA|child"> <level> <xsl:for-each select="Part"> <xsl:sort data-type="number" select="substring(code/name,string-length(ancestor::Part[1]/code/name) +1+boolean(ancestor::Part))"/> <xsl:copy-of select="code/name"/> <xsl:apply-templates select="child"/> </xsl:for-each> </level> </xsl:template> </xsl:stylesheet> Will return this result: <level> <name>1</name> <name>2</name> <name>5</name> <level> <name>5-3</name> <name>5-4</name> <level> <name>abc</name> <name>def</name> </level> </level> </level>
|
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
|

Cart








