Project

Profile

Help

Bug #651

closed

Error when cast used in XQuery attribute constructor

Added by Anonymous over 19 years ago. Updated almost 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XQuery conformance
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Legacy ID:
sf-1251789
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

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;

    }
Actions #1

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

Also available in: Atom PDF