Subject: RE: [xsl] re-ordering nodes/partial sort From: "Kevin Bird" <kevin.bird@xxxxxxxxxxxxx> Date: Sun, 10 Oct 2004 19:38:02 +0100 |
Hi David Thanks for the answer(s). It is not a straighforward sort. Looking at in terms of priority: Bed & Breakfast --> priority 1 Bed & Breakfast (child) --> priority 2 Half Board --> priority 3 Half Board (child) --> priority 4 Full Board --> priority 5 Full Board (child) --> priority 6 All other <supp> nodes are output before the priority ones above (in document order). Kind regards. -- Kevin > -----Original Message----- > From: M. David Peterson [mailto:m.david@xxxxxxxxxx] > Sent: 10 October 2004 17:38 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] re-ordering nodes/partial sort > > Hey Kevin, > > Does this have to be in document order of the input (or based on an index > of > some sort) or is this something that can solved simply by using the sort > element? Something as simple as this... > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:template match="/"> > <supplements> > <xsl:apply-templates select="supplements/supp"> > <xsl:sort select="supp-desc"/> > </xsl:apply-templates> > </supplements> > </xsl:template> > > <xsl:template match="supp"> > <xsl:copy-of select="."/> > </xsl:template> > > </xsl:stylesheet> > > Will give you this... > > <?xml version="1.0" encoding="UTF-8"?> > <supplements> > <supp> > <supp-desc>Balcony</supp-desc> > <supp-price>8.00</supp-price> > </supp> > <supp> > <supp-desc>Bed & Breakfast</supp-desc> > <supp-price>4.00</supp-price> > </supp> > <supp> > <supp-desc>Bed & Breakfast (child)</supp-desc> > <supp-price>2.00</supp-price> > </supp> > <supp> > <supp-desc>Full Board</supp-desc> > <supp-price>60.00</supp-price> > </supp> > <supp> > <supp-desc>Full Board (child)</supp-desc> > <supp-price>30.00</supp-price> > </supp> > <supp> > <supp-desc>Half Board</supp-desc> > <supp-price>30.00</supp-price> > </supp> > <supp> > <supp-desc>Half Board (child)</supp-desc> > <supp-price>15.00</supp-price> > </supp> > <supp> > <supp-desc>Sea View</supp-desc> > <supp-price>10.00</supp-price> > </supp> > </supplements> > > But it seems that you have a requirement to sort based on doc order as > well? > Let me know if this is sufficient or if you need further help. The indexed > solution is pretty straight forward as well but if this works, no need to > further complicate the code if you don't have to. > > Best regards, > > <M:D/> > > > Kevin Bird wrote: > > Hi > > > > In the following structure I can receive 1 or many <supp> nodes. Some of > > the <supp> nodes need re-arranging depending on their <supp-desc>. The > > order is: Bed & Breakfast, Bed & Breakfast (child), Half Board, > > Half Board (child), Full Board and Full Board (child). Any <supp> with a > > <supp-desc> that is not one of the above appear before them in the > > output. > > > > Any suggestions would be greatly appreciated. > > > > --INPUT-- > > > > <supplements> > > <supp> > > <supp-desc>Sea View</supp-desc> > > <supp-price>10.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Half Board</supp-desc> > > <supp-price>30.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Bed & Breakfast</supp-desc> > > <supp-price>4.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Full Board</supp-desc> > > <supp-price>60.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Half Board (child)</supp-desc> > > <supp-price>15.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Full Board (child)</supp-desc> > > <supp-price>30.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Bed & Breakfast (child)</supp-desc> > > <supp-price>2.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Balcony</supp-desc> > > <supp-price>8.00</supp-price> > > </supp> > > </supplements> > > > > --REQUIRED OUTPUT-- > > > > <supplements> > > <supp> > > <supp-desc>Sea View</supp-desc> > > <supp-price>10.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Balcony</supp-desc> > > <supp-price>8.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Bed & Breakfast</supp-desc> > > <supp-price>4.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Bed & Breakfast (child)</supp-desc> > > <supp-price>2.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Half Board</supp-desc> > > <supp-price>30.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Half Board (child)</supp-desc> > > <supp-price>15.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Full Board</supp-desc> > > <supp-price>60.00</supp-price> > > </supp> > > <supp> > > <supp-desc>Full Board (child)</supp-desc> > > <supp-price>30.00</supp-price> > > </supp> > > </supplements> > > > > Thanks. > > > > -- > > Kevin
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] re-ordering nodes/partial, M. David Peterson | Thread | Re: [xsl] re-ordering nodes/partial, Anton Triest |
Re: [xsl] re-ordering nodes/partial, M. David Peterson | Date | Re: [xsl] Xslt transform & grouping, row.filter |
Month |