Subject: RE: [xsl] Sorting and re-ordering down a hierarchy From: "McNally, David" <David.McNally@xxxxxxxxxx> Date: Tue, 22 Jul 2003 09:15:42 -0400 |
When defining what to use for sorting, you do so in the context of the nodes being sorted - so where you have, in both cases: <xsl:sort select="node/rank" data-type="number" order="ascending"/> I think you should have <xsl:sort select="rank" data-type="number" order="ascending"/> With that change I think your code works fine. David. -- David McNally Moody's Investors Service Software Engineer 99 Church St, NY NY 10007 David.McNally@xxxxxxxxxx (212) 553-7475 > -----Original Message----- > From: Ragulf Pickaxe [mailto:jawxml@xxxxxxxxxxx] > Sent: Tuesday, July 22, 2003 4:21 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] Sorting and re-ordering down a hierarchy > > > Hi, > > I did not see any response on this (except for one who said > he used Perl > instead), so I tried myself. > The templates below, I thought would do what was wanted, but > I only get it > to sort on the 1st level, not on the second level. I do not know why. > > Does anybody else have a solution, and can anyone tell me why > my solution > does not work? > > Regards, > Ragulf Pickaxe :) > > > <xsl:template match="/"> > <output> > <xsl:apply-templates select="input"/> > </output> > </xsl:template> > > <xsl:template match="input"> > <xsl:apply-templates select="node"> > <xsl:sort select="node/rank" data-type="number" > order="ascending"/> > </xsl:apply-templates> > </xsl:template> > > <xsl:template match="node"> > <node> > <xsl:copy-of select="rank"/> > <xsl:apply-templates select="node"> > <xsl:sort select="node/rank" data-type="number" > order="ascending"/> > </xsl:apply-templates> > </node> > </xsl:template> > > > ><input> > ><node> > > <rank>2</rank> > > <node> > > <rank>88</rank> > > </node> > > <node> > > <rank>7</rank> > > </node> > > <node> > > <rank>66</rank> > > </node> > ></node> > ><node> > > <rank>1</rank> > > <node> > > <rank>3</rank> > > </node> > > <node> > > <rank>2</rank> > > </node> > > <node> > > <rank>1</rank> > > </node> > ></node> > ></input> > > The output I get on this is: > <output> > <node> > <rank>1</rank> > <node> > <rank>3</rank> > </node> > <node> > <rank>2</rank> > </node> > <node> > <rank>1</rank> > </node> > </node> > <node> > <rank>2</rank> > <node> > <rank>88</rank> > </node> > <node> > <rank>7</rank> > </node> > <node> > <rank>66</rank> > </node> > </node> > </output> > > _________________________________________________________________ > MSN 8 with e-mail virus protection service: 2 months FREE* > http://join.msn.com/?page=features/virus > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > --------------------------------------- The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Thank you. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Sorting and re-ordering d, Américo Albuquerque | Thread | RE: [xsl] Sorting and re-ordering d, Ragulf Pickaxe |
Re: [xsl] printing the input xml wi, Peter_Ivan | Date | RE: [xsl] Sorting and re-ordering d, Américo Albuquerque |
Month |