[xquery-talk] sorting not working
Martin Probst
martin at x-hive.com
Fri Nov 18 12:06:11 PST 2005
Hi,
I think the problem is that $copies is bound to the @id attribute of
"bad". Then ordering by $copies//something will do nothing, as that
expression is always the empty sequence (attributes don't have
children). I think you mixed up your variables.
You should probably rethink your query anyways, e.g. first selecting the
@ids into $copies, then again traversing the document to find those
items, that have this @id tag is quite superfluous. Same for the
$bad[@id = $copies], it's checking again for a condition you've already
made sure.
Martin Probst
X-Hive
On Thu, 2005-11-17 at 15:45 -0500, Cindy Girard wrote:
> 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