From: Paula H. <ph...@vi...> - 2005-10-31 07:05:32
|
Hello, =20 I have an xquery with the following FLWOR expresion: =20 =20 for $x in /document let $actualDate :=3D $x/Date let $actualCategory :=3D $x/category let $actualSortBy :=3D ( if ($sortBy =3D "dateRecorded")=20 then $actualDate=20 else if ($sortBy =3D "category") then $actualCategory) order by $actualSortBy descending return=20 <result>=20 {=20 <id> {data($x/id} </id>,=20 <category> {data($actualCategory)} </category>, <dateRecorded>{data($actualDate)}</dateRecorded>, } </result> =20 My problem is that I would like to dynamically determine the sort order of the results i.e ascending/descending based on a parameters supplied to the xquery:=20 I have tried: =20 1. order by $actualSortBy $sortOrder 2. order by (if ($sortOrder =3D"ascending") then ($actualSortBy = ascending) else ($actualSortBy descending) and numerous other attempts but none are valid xqueries. =20 I would greatly appreciate it if anyone can assist with this issue and show how this might be achieved? Regards, Paula=20 =20 |