Different behaviour on exception
Hi all, I have the following code [1] that I expect to raise a xml parser exception but it raises a typecast exception [2]. Instead I get the expected exception [3] when substituting the call to local:h with direct parse -xml() (as for the snippet in the comment). Any clue? Thanks, Marco.
[1]
declare function local:f($rdf as node()){
$rdf
};
declare function local:h(){
parse-xml("xxx")
};
declare function local:g(){
let $rdf := local:h() (: parse-xml("xxx") :)
let $validate := local:f($rdf) (:$rdf:)
return ($validate)
};
local:g()[2] Stopped at /home/lettere/tmp/basex80/basex/file, 2/18: [XPTY0004] Cannot cast from empty-sequence() to node().
[3] Stopped at /home/lettere/tmp/basex80/basex/file, 11/26: [FODC0006] SAX: "file:/home/lettere/tmp/basex80/basex/file" (Line 1): Content is not allowed in prolog.
...resolved in the new snapshot. The reason was that the erroneous parse-xml() function was pre-evaluated and substituted with an error() function, which couldn't be passed on to the next function.
Quoted text · Marco Lettere · 37 lines
On Wed, Aug 6, 2014 at 11:10 PM, Marco Lettere <marco.lettere at dedalus.eu> wrote: > Hi all, > I have the following code [1] that I expect to raise a xml parser > exception but it raises a typecast exception [2]. > Instead I get the expected exception [3] when substituting the call to > local:h with direct parse -xml() (as for the snippet in the comment). > Any clue? > Thanks, > Marco. > > [1] > declare function local:f($rdf as node()){ > $rdf > }; > > declare function local:h(){ > parse-xml("xxx") > }; > > declare function local:g(){ > let $rdf := local:h() (: parse-xml("xxx") :) > let $validate := local:f($rdf) (:$rdf:) > return ($validate) > }; > > local:g() > > [2] > Stopped at /home/lettere/tmp/basex80/basex/file, 2/18: > [XPTY0004] Cannot cast from empty-sequence() to node(). > > [3] > Stopped at /home/lettere/tmp/basex80/basex/file, 11/26: > [FODC0006] SAX: "file:/home/lettere/tmp/basex80/basex/file" (Line 1): > Content is not allowed in prolog. >
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.