Subject: RE: [xsl] muliple level sorting using xsl:sort From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 5 Sep 2005 12:14:50 +0100 |
I think you need to define as your sort key the numeric value of the code/name after the last hyphen, if there is one. In 2.0 this is easy: <xsl:sort select="number(replace(code/name, '(.*-)?(\d*)', '$2'))"/> Harder in 1.0, because there's no straightforward way to extract the stuff after the last hyphen in a single XPath expression. But perhaps you could exploit the redundancy in your data, with something like: <xsl:sort select="number(substring-after(code/name, concat(ancestor::Part[1]/code/name, '-')))"/> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Aravind J [mailto:aravindjp@xxxxxxxxx] > Sent: 05 September 2005 10:19 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] muliple level sorting using xsl:sort > > Hi , > I am trying to sort an xml data like > <AAAA> > <desc>SampleXML</desc> > <Part> > <code> > <name>1</name> > </code> > </Part> > <Part> > <code> > <name>5</name> > </code> > <child type="child"> > <Part> > <code><name>5-4</name></code> > <child type="child"> > <Part> > <code><name>abc</name></code> > </Part> > <Part> > <code><name>def</name></code> > </Part> > </child> > </Part> > <Part> > <code><name>5-3</name></code> > </Part> > </child> > </Part> > <Part> > <code> > <name>2</name> > </code> > </Part> > </AAAA> > > > 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. > > Any idea how we can sort sub parts ie (child <Part> ) > also in this case . > > Thanks & Regards > Aravind > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] muliple level sorting usi, Joris Gillis | Thread | Re: [xsl] muliple level sorting usi, Dimitre Novatchev |
Re: [xsl] muliple level sorting usi, Joris Gillis | Date | Re: [xsl] Terminate <xsl:for-each>, aaron apigo |
Month |