Java method signature: no empty sequence allowed
Sunday, 17 June 2012 · 6 messages · last reply 20 Jun 2012
MU
Mattijs Ugen17 Jun 2012 13:50 #
Dear all,
Calling methods from a QueryModule works nicely, yet I can't seem to get a particular method signature to work from XQuery. The function in question should be passed a string and the result of a path expression, yielding attribute values as strings. For example:
ns:method($value, $context/ancestor-or-self::*/@some-attr/string())Intuitively, I figure the signature for this method in the QueryModule should be:
public String method(Str previous, Value additionals) { ...However, trying to use this method with BaseX won't work. The query editor accepts the syntax, but states "PXML:combine method: no empty sequence allowed".
Changing the signature to Seq, ItemSeq or even Empty changes nothing; it keeps telling me (I think) the expression *could* yield an empty sequence and the method does not support it (even tho Empty is a valid value for Value, is it not?).
How would I define my method so that BaseX will accept it?
Kind regards,
Mattijs Ugen
CG
Christian Grün17 Jun 2012 20:50 #
Hi Mattijs,
thanks for your mail. I removed a check for empty sequences in our code base that looked obsolete to me [1]. Feel free to check out the latest snapshot [2] and give us some feedback if the problem persists.
Christian
[1] https://github.com/BaseXdb/basex/commit/f98e6200bef66409f3a70a94b0352cc383eb7af3 [2] http://files.basex.org/releases/latest/
Quoted text · Mattijs Ugen · 33 lines
On Sun, Jun 17, 2012 at 1:50 PM, Mattijs Ugen <m.ugen at student.utwente.nl> wrote: > Dear all, > > Calling methods from a QueryModule works nicely, yet I can't seem to get a > particular method signature to work from XQuery. The function in question > should be passed a string and the result of a path expression, yielding > attribute values as strings. For example: > > ns:method($value, $context/ancestor-or-self::*/@some-attr/string()) > > Intuitively, I figure the signature for this method in the QueryModule > should be: > > public String method(Str previous, Value additionals) { ... > > However, trying to use this method with BaseX won't work. The query editor > accepts the syntax, but states "PXML:combine method: no empty sequence > allowed". > > Changing the signature to Seq, ItemSeq or even Empty changes nothing; it > keeps telling me (I think) the expression *could* yield an empty sequence > and the method does not support it (even tho Empty is a valid value for > Value, is it not?). > > How would I define my method so that BaseX will accept it? > > Kind regards, > > Mattijs Ugen > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
MU
Mattijs Ugen17 Jun 2012 21:00 #
Thanks for your reply, I'll give it a go as soon as I get the chance.
Managed to work around the issue for now using a double join-string, curious what kind of performance impact that has had :)
Mattijs
Quoted text · Christian Grün · 48 lines
On 06/17/2012 08:50 PM, Christian Grün wrote: > Hi Mattijs, > > thanks for your mail. I removed a check for empty sequences in our > code base that looked obsolete to me [1]. Feel free to check out the > latest snapshot [2] and give us some feedback if the problem persists. > > Christian > > [1] https://github.com/BaseXdb/basex/commit/f98e6200bef66409f3a70a94b0352cc383eb7af3 > [2] http://files.basex.org/releases/latest/ > > ___________________________ > > On Sun, Jun 17, 2012 at 1:50 PM, Mattijs Ugen<m.ugen at student.utwente.nl> wrote: >> Dear all, >> >> Calling methods from a QueryModule works nicely, yet I can't seem to get a >> particular method signature to work from XQuery. The function in question >> should be passed a string and the result of a path expression, yielding >> attribute values as strings. For example: >> >> ns:method($value, $context/ancestor-or-self::*/@some-attr/string()) >> >> Intuitively, I figure the signature for this method in the QueryModule >> should be: >> >> public String method(Str previous, Value additionals) { ... >> >> However, trying to use this method with BaseX won't work. The query editor >> accepts the syntax, but states "PXML:combine method: no empty sequence >> allowed". >> >> Changing the signature to Seq, ItemSeq or even Empty changes nothing; it >> keeps telling me (I think) the expression *could* yield an empty sequence >> and the method does not support it (even tho Empty is a valid value for >> Value, is it not?). >> >> How would I define my method so that BaseX will accept it? >> >> Kind regards, >> >> Mattijs Ugen >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MU
Mattijs Ugen20 Jun 2012 19:36 #
Quoted text · Mattijs Ugen · 1 line
>> [2] http://files.basex.org/releases/latest/
Is it me or is the current latest build missing the package
org.basex.query.item ?
Running the GUI from the commandline gives an healthy amount of spam stating classes from that packages cant be found. Builds for 7.2 do have this package included.
Using BaseX.jar from the root of the zip.
Mattijs
CG
Christian Grün20 Jun 2012 19:40 #
Quoted text · Mattijs Ugen · 2 lines
> Is it me or is the current latest build missing the package > org.basex.query.item ?
The "item" package has been renamed to "value".
Christian
MU
Mattijs Ugen20 Jun 2012 20:40 #
Quoted text · Christian Grün · 4 lines
>> Is it me or is the current latest build missing the package >> org.basex.query.item ? > > The "item" package has been renamed to "value".
My bad, i was importing a stale version of my module, compiled against BaseX.jar version 7.2.1.
Furthermore, I can confirm your fix works for me; using Value in the method signature now works as previously expected.
Thanks for your quick fix!
Mattijs
Written for BaseX 7.2, 7.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery