This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 3308 - Which error to raise for attributes with the same node-name in a direct element constructor?
Summary: Which error to raise for attributes with the same node-name in a direct eleme...
Status: CLOSED WONTFIX
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Don Chamberlin
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-01 21:14 UTC by Ying Lu
Modified: 2006-06-06 16:59 UTC (History)
0 users

See Also:


Attachments

Description Ying Lu 2006-06-01 21:14:56 UTC
For the following query,

<elem attr="val1" attr="val2" attr2="val3"/>

it can raise error XQST0040, according to XQuery specification section 3.7.1.1, "If the attributes in a direct element constructor do not have distinct expanded QNames as their respective node-name properties, a static error is raised [err:XQST0040]."

It can also raise error XQDY0025, based on section 3.7.1.3 bullet 5.d, "attributes consist of all the attributes specified in the start tag as
described in 3.7.1.1 Attributes, together with all the attribute nodes in the
content sequence, in implementation-dependent order. If two or more of these
attributes have the same node-name, a dynamic error is raised [err:XQDY0025]."

Should both error codes be allowed for the sample query? Please clarify.

Thanks,
Ying
Comment 1 Michael Kay 2006-06-04 22:28:21 UTC
If a query contains a static error then the evaluation phase will never take place and therefore a dynamic error will never be raised. I think there's a clear distinction here between the static error that occurs when the attribute names are known statically, and the dynamic error that occurs when they are computed.

Michael Kay (personal response)
Comment 2 Ying Lu 2006-06-05 18:37:22 UTC
If that is the intention, please clarify in the specification, as the section 3.7.1.3 bullet 5.d says, "attributes consist of all the attributes specified in the start tag as described in 3.7.1.1 Attributes...."

An implementation can choose to check the attribute name during the evaluation phase, therefore raise the dynamic error instead of the static error. Both are allowed in the current specification.

Thanks,
Ying
Comment 3 Michael Kay 2006-06-06 16:59:25 UTC
The Working Group discussed this on 2006-06-06 and decided that no change to the specification is needed.

In a direct element constructor, the presence of two conflicting attributes is a static error, which means that it can and must be detected statically (which means it must be reported, using error code XQST0040, even if it occurs in code that is never executed). 

In a computed element constructor, it's not possible in general to detect the error statically. It's therefore defined as a dynamic error, and it's only mandatory to report the error if the code is actually executed. But note that section 2.3.1 says that dynamic errors "may" be detected during the static phase: in this case this means that if you use a computed element constructor and the compiler can work out in advance that the attribute names will conflict, it is allowed to report the error XQDY0025 statically.

I am closing this as "Won't fix". If you feel there are issues that we haven't addressed here, please feel free to reopen the bug.

Michael Kay
for the XQuery Working Group