|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] reversing element ordering, with a caveatHoward Katz howardk at fatdog.comSun Mar 15 18:04:27 PST 2009
I have a series of books ordered chronologically by publication date, 1942 to 2009. I want to generate a file in which the books have the reverse chronological ordering, 2009 to 1942, but with the caveat that books *within* a particular year need to maintain the original document order relative to that year. In the following, the catid attributes within a particular year remain in ascending order after the transformation. (The catid's are used here only for demonstration purposes; they're not present in the actual document.) I'd be happy to see a solution either in XQuery or in XSLT. Here's some sample input and the output. Input: <library> <book pubYear='1942' catid='1' > <otherStuff ... /></book> <book pubYear='1942' catid='2' > <otherStuff ... /></book> <book pubYear='1942' catid=' 3 ' > <otherStuff ... /></book> ... <book pubYear='2009' catid=' 2011' > <otherStuff ... /></book> <book pubYear='2009' catid=' 2012 ' > <otherStuff ... /></book> <book pubYear='2009' catid=' 2013 ' > <otherStuff ... /></book> </library> Output: <library> <book pubYear='2009' catid=' 2011' > <otherStuff ... /></book> <book pubYear='2009' catid=' 2012 ' > <otherStuff ... /></book> <book pubYear='2009' catid=' 2013 ' > <otherStuff ... /></book> ... <book pubYear='1942' catid=' 1 ' > <otherStuff ... /></book> <book pubYear='1942' catid=' 2 ' > <otherStuff ... /></book> <book pubYear='1942' catid=' 3 ' > <otherStuff ... /></book> </library> TIA, Howard
|
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
|






