Re: [xquery-talk] "order by" over dynamically generated sequence

2017-12-12 Thread Jozef Aerts

Thanks Michael!I looked into that and I think this means I need to use the 3-argument sort function isn't it?I still do not exactly understand how that would work in my case. I have to sort "ItemGroupData" based on the values of ItemOID in something like:      where the values from @ItemOID come from an XPath _expression_ on another file which results in a sequence.Many thanks,JozefMichael Kay  hat am 11. Dezember 2017 um 23:13 geschrieben:Use the higher-order sort() function in 3.1. This gives you much more flexibility in computing a sort key, and the sort key can be any sequence. The only limitation is it's tricky if you want some components (but not all) to be in descending order.Michael KaySaxonicaOn 11 Dec 2017, at 18:06, Jozef Aerts  wrote:I am writing an XQuery to validate whether "records" (parent nodes) are unique based on a number of child elements and their attributes (like primary keys in relational). I do not know these "keys" in advance however, as they are generated from a query on another document. So sometimes I have only two "keys", but sometimes 10."order by" uses a list of comma-separated values, but as I don't know these values in advance, ...Essentially, what I intend to do is something like:$keys := ...  (: returns a sequence :)...for ...order by $keys  (: throws an error of course at it expects a list of comma-separated values :)Any tips how this can be done?Many thanks in advance,Jozef___talk@x-query.comhttp://x-query.com/mailman/listinfo/talk ___talk@x-query.comhttp://x-query.com/mailman/listinfo/talk
 
___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] "order by" over dynamically generated sequence

2017-12-11 Thread Michael Kay
Use the higher-order sort() function in 3.1. This gives you much more 
flexibility in computing a sort key, and the sort key can be any sequence. The 
only limitation is it's tricky if you want some components (but not all) to be 
in descending order.

Michael Kay
Saxonica

> On 11 Dec 2017, at 18:06, Jozef Aerts  wrote:
> 
> 
> I am writing an XQuery to validate whether "records" (parent nodes) are 
> unique based on a number of child elements and their attributes (like primary 
> keys in relational). I do not know these "keys" in advance however, as they 
> are generated from a query on another document. So sometimes I have only two 
> "keys", but sometimes 10.
> 
> "order by" uses a list of comma-separated values, but as I don't know these 
> values in advance, ...
> 
> Essentially, what I intend to do is something like:
> 
> $keys := ...  (: returns a sequence :)
> ...
> for ...
> order by $keys  (: throws an error of course at it expects a list of 
> comma-separated values :)
> 
> Any tips how this can be done?
> 
> Many thanks in advance,
> 
> Jozef
> 
> ___
> talk@x-query.com
> http://x-query.com/mailman/listinfo/talk

___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk

Re: [xquery-talk] "order by" over dynamically generated sequence

2017-12-11 Thread Michael Kay
Use the higher-order sort() function in 3.1. This gives you much more 
flexibility in computing a sort key, and the sort key can be any sequence. The 
only limitation is it's tricky if you want some components (but not all) to be 
in descending order.

Michael Kay
Saxonica

> On 11 Dec 2017, at 18:06, Jozef Aerts  > wrote:
> 
> 
> I am writing an XQuery to validate whether "records" (parent nodes) are 
> unique based on a number of child elements and their attributes (like primary 
> keys in relational). I do not know these "keys" in advance however, as they 
> are generated from a query on another document. So sometimes I have only two 
> "keys", but sometimes 10.
> 
> "order by" uses a list of comma-separated values, but as I don't know these 
> values in advance, ...
> 
> Essentially, what I intend to do is something like:
> 
> $keys := ...  (: returns a sequence :)
> ...
> for ...
> order by $keys  (: throws an error of course at it expects a list of 
> comma-separated values :)
> 
> Any tips how this can be done?
> 
> Many thanks in advance,
> 
> Jozef
> 
> ___
> talk@x-query.com 
> http://x-query.com/mailman/listinfo/talk

___
talk@x-query.com
http://x-query.com/mailman/listinfo/talk