Calling the sort function with two arguments

Wednesday, 22 March 2017 · 3 messages
MH
Martin Honnen22 Mar 2017 16:24 #
According to https://www.w3.org/TR/xpath-functions-31/#func-sort the sort function allows one or two or three arguments, however when doing sort((5, 3, 4, 1), default-collation()) in BaseX 8.6.2 I get an error
java.lang.ArrayIndexOutOfBoundsException: 2
	at org.basex.query.func.fn.FnSort.iter(FnSort.java:34)
	at org.basex.query.QueryContext.iter(QueryContext.java:394)
	at org.basex.query.scope.MainModule.iter(MainModule.java:117)
	at org.basex.query.QueryContext.iter(QueryContext.java:330)
	at org.basex.query.QueryContext.cache(QueryContext.java:609)
	at org.basex.query.QueryProcessor.cache(QueryProcessor.java:113)
	at org.basex.core.cmd.AQuery.query(AQuery.java:86)
	at org.basex.core.cmd.XQuery.run(XQuery.java:22)
	at org.basex.core.Command.run(Command.java:257)
	at org.basex.core.Command.execute(Command.java:93)
	at org.basex.gui.GUI.exec(GUI.java:471)
	at org.basex.gui.GUI.access$300(GUI.java:44)
	at org.basex.gui.GUI$6.run(GUI.java:413)
A similar error occurs with sort((5, 3, 4, 1), ()) Is BaseX 8.6.2 not yet in line with the freshly published spec? Regards, Martin Honnen
CG
Christian Grün22 Mar 2017 16:27 #
Martin, Thanks for the hint, looks like a little bug (that has actually been caused by the redefinition of this function). Until this has been fixed, the two following alternatives should do the job:
  fn:sort((5, 3, 4, 1))

  fn:sort((5, 3, 4, 1), default-collation(), function($e) { $e })
Best, Christian
Quoted text · Martin Honnen · 34 lines
On Wed, Mar 22, 2017 at 4:24 PM, Martin Honnen <martin.honnen at gmx.de> wrote: > > According to https://www.w3.org/TR/xpath-functions-31/#func-sort the sort > function allows one or two or three arguments, however when doing > > sort((5, 3, 4, 1), default-collation()) > > in BaseX 8.6.2 I get an error > > java.lang.ArrayIndexOutOfBoundsException: 2 > at org.basex.query.func.fn.FnSort.iter(FnSort.java:34) > at org.basex.query.QueryContext.iter(QueryContext.java:394) > at org.basex.query.scope.MainModule.iter(MainModule.java:117) > at org.basex.query.QueryContext.iter(QueryContext.java:330) > at org.basex.query.QueryContext.cache(QueryContext.java:609) > at org.basex.query.QueryProcessor.cache(QueryProcessor.java:113) > at org.basex.core.cmd.AQuery.query(AQuery.java:86) > at org.basex.core.cmd.XQuery.run(XQuery.java:22) > at org.basex.core.Command.run(Command.java:257) > at org.basex.core.Command.execute(Command.java:93) > at org.basex.gui.GUI.exec(GUI.java:471) > at org.basex.gui.GUI.access$300(GUI.java:44) > at org.basex.gui.GUI$6.run(GUI.java:413) > > > A similar error occurs with > > sort((5, 3, 4, 1), ()) > > Is BaseX 8.6.2 not yet in line with the freshly published spec? > > Regards, > > Martin Honnen
CG
Christian Grün22 Mar 2017 16:37 #
Hi Martin, The bug has been fixed in the latest snapshot [1]. Best, Christian [1] http://files.basex.org/releases/latest/
Quoted text · Christian Grün · 50 lines
On Wed, Mar 22, 2017 at 4:27 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Martin, > > Thanks for the hint, looks like a little bug (that has actually been > caused by the redefinition of this function). Until this has been > fixed, the two following alternatives should do the job: > > fn:sort((5, 3, 4, 1)) > > fn:sort((5, 3, 4, 1), default-collation(), function($e) { $e }) > > Best, > Christian > > > On Wed, Mar 22, 2017 at 4:24 PM, Martin Honnen <martin.honnen at gmx.de> wrote: >> >> According to https://www.w3.org/TR/xpath-functions-31/#func-sort the sort >> function allows one or two or three arguments, however when doing >> >> sort((5, 3, 4, 1), default-collation()) >> >> in BaseX 8.6.2 I get an error >> >> java.lang.ArrayIndexOutOfBoundsException: 2 >> at org.basex.query.func.fn.FnSort.iter(FnSort.java:34) >> at org.basex.query.QueryContext.iter(QueryContext.java:394) >> at org.basex.query.scope.MainModule.iter(MainModule.java:117) >> at org.basex.query.QueryContext.iter(QueryContext.java:330) >> at org.basex.query.QueryContext.cache(QueryContext.java:609) >> at org.basex.query.QueryProcessor.cache(QueryProcessor.java:113) >> at org.basex.core.cmd.AQuery.query(AQuery.java:86) >> at org.basex.core.cmd.XQuery.run(XQuery.java:22) >> at org.basex.core.Command.run(Command.java:257) >> at org.basex.core.Command.execute(Command.java:93) >> at org.basex.gui.GUI.exec(GUI.java:471) >> at org.basex.gui.GUI.access$300(GUI.java:44) >> at org.basex.gui.GUI$6.run(GUI.java:413) >> >> >> A similar error occurs with >> >> sort((5, 3, 4, 1), ()) >> >> Is BaseX 8.6.2 not yet in line with the freshly published spec? >> >> Regards, >> >> Martin Honnen

⚡Generated with XQuery