Hello Michael,
and now I observed another variant of the problem concerning fn:name (and
fn:local-name):
omitting the argument may yield no static error, but an incorrect evaluation
result. (I am sorry that the example is so convoluted - I do not have another
one). Consider the following code:
for $v in $doc/PG[@NAME eq $c/@sGroup2]/resultset/row/
string-join(
for $f in $srcFields
let $fdata := *[name() eq $f]
return
(: replace($fdata, "^NULL$", ""), :)
if ($fdata eq "NULL") then "" else string($fdata),
"^")
order by $v return $v
The point is that the result should be the same, regardless if I write, as shown
name()
or
name(.)
However, the evalution results are different: without the dot, the predicate
produces an empty result, erroneously. With the dot, I get the correct result.
(For example, I get ^^^ when omitting the dot, otherwise and correctly this:
SE^^9836^Depo-Provera 150 mg/ml)
Interestingly, if I replace
if ($fdata eq "NULL") then "" else string($fdata),
by the equivalent
replace($fdata, "^NULL$", ""),
(commented out in the snippet above), THEN I get the correct result regardless
if name() or name(.) is used.
Unfortunately I observed this behaviour only in the context of a rather complex
program importing modules - I have not yet succeeded in producing a simple
testcase. However, if you want me to, I will try to produce a testcase which at
least is contained in a single query.
Kind regards,
Hans-Juergen
|