Hello all,
I've stumbled upon an issue with the latest version and in particular
the code I provide was working with 8.0 snapshot up to build 496C381 and
with all previous official versions of course. Build 151df63 is the
first build I'm aware of the difference.
Shortly. In an input document I have a list of env nodes (sort of <env
name="n">v</env>). They need to be parsed and "xquery:eval(uated)" in
sequence because following env nodes may refer to preceding ones (i.e.
<env name="n1">v1</env>, <env name="n2">{$n1}</env>).
I've managed to do the job with the following code but now (as described
in the preamble) I get the following cast exception in the xquery:eval:
Stopped at [...]/file, 9/31: ---> (this points to the line with the
xquery:eval call)
[XPTY0117] Cannot cast xs:untypedAtomic to xs:QName.
I've absolutely no idea why it started giving this error and even
looking at the queryplan is too difficult in such a scenario for me.
Anyone can help me out?
Thanks,
This is the smallest example of the code I was able to produce:
declare function local:declarations($env as map(*)){
string-join(
map:keys($env) ! ( "declare variable $" || . || " external;")
)
};
declare function local:updateenv($envnode as node(), $env){
let $q := local:declarations($env) || serialize($envnode)
let $dynnode := xquery:eval($q, $env)
return
map:new((
map:entry($envnode/data(@name), $dynnode/text()),
$env
))
};
declare function local:buildenv($envnodes as node()*, $env as map(*)) {
if(empty($envnodes)) then $env
else
let $envnode := $envnodes[1]
let $newenv := local:updateenv($envnode, $env)
return map:new(( $newenv, local:buildenv($envnodes[position() > 1],
$newenv)))
};
map:serialize(
local:buildenv((<env name="n1">v1</env>,
<env name="n2">another {{$n1}}</env>
),
map{})
)