basex - XQuery: declare a function returning nothing -
declare variable $testseq item()* := (); declare function local:insertseq($target item()*, $position xs:integer?, $inserts item()*) item()* (:might great if have keyword represent nothing:) { fn:insert-before($target, 1, $inserts) (:change global sequence:) () (:simulate returning nothing, empty sequence:) }; element test { attribute haha {"&"}, local:insertseq($testseq, 1, ('a', 'b')), $testseq }
i need collect global sequence while script running. @ end of script release sequence. function insertseq
must return nothing. possible xquery? or there other tricks it?
error basex:
$ basex test.xqy stopped @ /users/jack/documents/shk/xsd2owl/workspace/xqy/test.xqy, 7/4: [xpty0004] item expected, sequence found: ("a", "b").
the answer on title of original question be:
declare function local:f() empty-sequence() { () };
as want solve specific problem, think creating new question title , corresponding problem description (including tiny example expected input , output).
in functional languages, such xquery, variables cannot reassigned once have been defined (see referential transparency). consequence, you’ll need use recursive functions repeatedly add values sequence. fn:fold-left can used well: feels challenging when being used first time, once understand does, don’t want miss is.
Comments
Post a Comment