[xquery-talk] sorting not working

Michael Kay mhk at mhk.me.uk
Thu Nov 17 20:59:43 PST 2005


It would help to (a) provide a sample source document, and (b) to say what
product you are using.

Also "not working" is very unspecific: what output/error do you get? 

The only thing I can see that's questionable is the repeated use of

x//compdate[1]

This selects every compdate descendant that is the first compdate child of
its parent. I suspect you intended to select the first descendant compdate
element, which can be written

(x//compdate)[1]

or

x/descendant::compdate[1]

Michael Kay
http://www.saxonica.com/





> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Cindy Girard
> Sent: 17 November 2005 20:46
> To: talk at xquery.com
> Subject: [xquery-talk] sorting not working
> 
> Hi.
> 
> Is there another way I can word this? I'm just not sure where the
> error is.
> 
> Thanks,
> Cindy
> 
> -------------------------------------
> 
> {for $copies in collection($g:collection)/bad[starts-with(@id 
> , $workid)]/@id
> let $bad :=collection($g:collection)/bad[@id = $copies]
> let $copyversion := string($bad/@copy),
>       $comporder :=$bad[@id = $copies]//compdate[1]/@value,
>       $printorder :=$bad[@id = $copies]//printdate[1]/@value,
>       $printdate := $bad[@id = $copies]//printdate/text(),
>       $repository := $bad//repository/institution/text(),
>       $repcount := count($repository)
>          order by $copies//compdate[1]/@value, 
> $copies//printdate[1]/@value
> return 
> if ($copies != $copyid)
> then
> <option 
> value="{$copies}"><striptags>{if(exists($copyversion))then 
> <wrap>{$copyversion}, </wrap>else ""} {string($printdate)} 
> ({if($repcount = 1) then $repository else <wrap>Multiple 
> ({$repcount}) Institutions</wrap> })</striptags></option>
> else "" 
> 
> }
> 
> 
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list