[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: re-ordering nodes/partial sort

Subject: RE: re-ordering nodes/partial sort
From: "Kevin Bird" <kevin.bird@xxxxxxxxxxxxx>
Date: Sun, 10 Oct 2004 22:29:46 +0100
partial sort
Hi Anton

Many thanks for the solution, it's appreciated.

--
Kevin

PS. Thanks to David for the earlier suggestions.



> -----Original Message-----
> From: Anton Triest [mailto:anton@xxxxxxxx]
> Sent: 10 October 2004 21:05
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  re-ordering nodes/partial sort
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     xmlns:my="urn:mine" extension-element-prefixes="my">
> 
>     <xsl:output method="xml" version="1.0" encoding="utf-8"
indent="yes"/>
>     <xsl:strip-space elements="*"/>
> 
>     <my:priorities>
>         <my:p desc="Bed &amp; Breakfast"/>
>         <my:p desc="Bed &amp; Breakfast (child)"/>
>         <my:p desc="Half Board"/>
>         <my:p desc="Half Board (child)"/>
>         <my:p desc="Full Board"/>
>         <my:p desc="Full Board (child)"/>
>     </my:priorities>
> 
>     <xsl:variable name="priorities"
> select="document('')/xsl:stylesheet/my:priorities/my:p"/>
> 
>     <xsl:template match="/supplements">
>         <supplements>
>             <xsl:apply-templates select="supp">
>                 <xsl:sort
> select="count($priorities[@desc=current()/supp-desc]/preceding::*)"/>
>             </xsl:apply-templates>
>         </supplements>
>     </xsl:template>
> 
>     <xsl:template match="supp">
>         <xsl:copy-of select="."/>
>     </xsl:template>
> 
> </xsl:stylesheet>
> 
> This will sort the supp elements according to the position in
> my:priorities.
> Not found supp-desc strings will have priority 0 so they will be first
> in output.
> 
> Of course you can also put the priorities in a separate file and
select
> it like
> 
>     <xsl:variable name="priorities"
> select="document('priorities.xml')/my:priorities/my:p"/>
> 
> Cheers,
> Anton
> 
> Kevin Bird wrote:
> 
> >Hi David
> >
> >Thanks for the answer(s). It is not a straighforward sort. Looking at
in
> >terms of priority:
> >
> >Bed &amp; Breakfast		--> priority 1
> >Bed &amp; 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.