Bug #651
closedError when cast used in XQuery attribute constructor
0%
Description
SourceForge user: mhkay
The spurious error message
Cannot cast to xdt:anyAtomicType
occurs when a "cast as" expression is used within an
enclosed expression in a direct attribute constructor,
for example
(the reason for this is that such enclosed expressions
must be initially processed without knowledge of the
in-scope namespaces, since namespace declarations can
follow attributes. So there is a "scan only" mode of
parsing, and in this mode any reference to an atomic
type name is treated temporarily as a reference to
xdt:anyAtomicType. But a cast to xdt:anyAtomicType is
not permitted, and Saxon 8.5 is checking for this error
during the "scan only" phase of processing).
Source fix: at line664 of
net.sf.saxon.expr.ExpressionParser.java, change
if (scanOnly) {
return Type.ANY_ATOMIC_TYPE;
}
to
if (scanOnly) {
return Type.STRING_TYPE;
}
Updated by Anonymous over 19 years ago
SourceForge user: mhkay
Logged In: YES
user_id=251681
The follow-up to this exposes another problem. Essentially
there is too much semantic processing being done when
enclosed expressions are parsed in scan-only mode.
Specifically, function calls are being fixed up to the
corresponding function declarations, which can lead to
spurious type errors later. The following patch fixes this:
In net.sf.saxon.expr.ExpressionParser before the line 1715
which reads
Expression[] arguments = new Expression[args.size()];
add
if (scanOnly) {
return StringValue.EMPTY_STRING;
}
Please register to edit this issue