<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16788" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=546033802-16032009><FONT
face="Century Gothic" color=#000080 size=2>Beautiful. I just removed the value()
function following the path ending in @pubYear, as Saxon returned an "Unknown
system function," and it worked perfectly.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546033802-16032009><FONT
face="Century Gothic" color=#000080 size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=546033802-16032009><FONT
face="Century Gothic" color=#000080 size=2>Thanks you,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=546033802-16032009><FONT
face="Century Gothic" color=#000080 size=2>Howard</FONT></SPAN></DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000080 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> talk-bounces@x-query.com
[mailto:talk-bounces@x-query.com] <B>On Behalf Of </B>Brian
Maso<BR><B>Sent:</B> Sunday, March 15, 2009 7:24 PM<BR><B>To:</B> Howard Katz;
talk@x-query.com<BR><B>Subject:</B> Re: [xquery-talk] reversing element
ordering, with a caveat<BR></FONT><BR></DIV>
<DIV></DIV>In XQuery, I think its just a matter of running over the distinct
values of //book/@pubYear in descending order. Something like:<BR><BR>(* Maybe
there's a more elegant way of getting the sequence of years in descending
order? *)<BR>let $descending-distinct-years := distinct-values(for $v in
//book/@pubYear/value() order by $v descending return $v)<BR>for $year in
$descending-distinct-years<BR>return //book[@pubYear = $year]<BR><BR>This will
retain original document ordering for elements with the same @pubYear value,
but years will be descending from highest value to lowest.<BR><BR>Brian
Maso<BR><BR>
<DIV class=gmail_quote>On Sun, Mar 15, 2009 at 6:04 PM, Howard Katz <SPAN
dir=ltr><<A
href="mailto:howardk@fatdog.com">howardk@fatdog.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">I
have a series of books ordered chronologically by publication date,
1942<BR>to 2009. I want to generate a file in which the books have the
reverse<BR>chronological ordering, 2009 to 1942, but with the caveat that
books<BR>*within* a particular year need to maintain the original document
order<BR>relative to that year. In the following, the catid attributes
within a<BR>particular year remain in ascending order after the
transformation. (The<BR>catid's are used here only for demonstration
purposes; they're not present<BR>in the actual document.)<BR><BR>I'd be
happy to see a solution either in XQuery or in XSLT. Here's some<BR>sample
input and the output.<BR><BR>Input:<BR><BR><library><BR>
<book pubYear='1942' catid='1' ><BR>
<otherStuff ...
/></book><BR> <book pubYear='1942'
catid='2' ><BR>
<otherStuff ... /></book><BR>
<book pubYear='1942' catid=' 3 ' ><BR>
<otherStuff ...
/></book><BR> ...<BR><BR>
<book pubYear='2009' catid=' 2011' ><BR>
<otherStuff ...
/></book><BR> <book pubYear='2009'
catid=' 2012 ' ><BR>
<otherStuff ... /></book><BR>
<book pubYear='2009' catid=' 2013 ' ><BR>
<otherStuff ...
/></book><BR></library><BR><BR>Output:<BR><BR><library><BR>
<book pubYear='2009' catid=' 2011' ><BR>
<otherStuff ...
/></book><BR> <book pubYear='2009'
catid=' 2012 ' ><BR>
<otherStuff ... /></book><BR>
<book pubYear='2009' catid=' 2013 ' ><BR>
<otherStuff ...
/></book><BR> ...<BR><BR>
<book pubYear='1942' catid=' 1 ' ><BR>
<otherStuff ...
/></book><BR> <book pubYear='1942'
catid=' 2 ' ><BR>
<otherStuff ... /></book><BR>
<book pubYear='1942' catid=' 3 ' ><BR>
<otherStuff ...
/></book><BR></library><BR><BR>TIA,<BR>Howard<BR><BR>_______________________________________________<BR><A
href="mailto:talk@x-query.com">talk@x-query.com</A><BR><A
href="http://x-query.com/mailman/listinfo/talk"
target=_blank>http://x-query.com/mailman/listinfo/talk</A><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>