Reputation: 16651
Using BaseX 8.4.1 which implements XQuery 3.1
I want to order my query result by a certain attribute which contains numbers. Because I need to synchronize this result with a second dataset that stores the corresponding values as strings, I need to sort it as if it were strings, i.e., the values 1,3 and 20 should be sorted like this:
1
20
3
I tried order by $x[string(@value)]
and order by string($x[@value])
but that doesn't work.
Upvotes: 1
Views: 1340
Reputation: 11771
In both examples you place part of the expression in a predicate ([]
), which evaluates to a boolean and returns the expression before the predicate ($x
), when true.
order by $x/@value/string()
Upvotes: 2