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 5629 - [UPD] Namespace conflict when renaming attributes
Summary: [UPD] Namespace conflict when renaming attributes
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Update Facility (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Andrew Eisenberg
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-05 14:23 UTC by Michael Kay
Modified: 2008-05-20 23:40 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2008-04-05 14:23:56 UTC
In 2.4.4 clause 2b, a strict reading of the rule

If the namespace binding of $QName conflicts with any namespace binding in the namespaces property of the parent (if any) of $target, a dynamic error is raised [err:XUDY0023].

(in conjunction with the referenced definitions) suggests that if the new attribute name has namespace binding (null, null) and the target element has a namespace binding (null, "abc.uri"), then a conflict exists and XUDY0023 is raised. However, this situation is clearly not a conflict, in fact, it is likely to be very common and no trouble at all.

I suggest changing the rule to read:

If $QName has a non-absent namespace, and if the namespace binding of $QName conflicts with any namespace binding in the namespaces property of the parent (if any) of $target, a dynamic error is raised [err:XUDY0023].
Comment 1 Michael Kay 2008-04-07 17:36:45 UTC
I think this problem is actually rather more pervasive. Consider "rename", where the new name of the element has the namespace binding (null, null) (that is, no prefix, no namespace URI). The current rules imply that the namespace binding (null, null) is added to the namespaces property of the element. However, the namespaces property of an element should never contain such a namespace binding: see the third bullet in XDM 3.3.3: "For every element node whose name has no prefix, the element must have a a binding for the empty prefix to the namespace URI of the element name, or must have no binding for the empty prefix in the case where the name of the element has no namespace URI." That is, the association (null, null) is represented by the absence in the namespaces property of any binding of the form (null, X). 

So the action of "rename" in such a case should be to remove any namespace binding of the form (null, X). And in practice this is a much more desirable result, because it means that the updated document doesn't carry so many obsolete and no-longer-used namespace bindings.
Comment 2 Jonathan Robie 2008-04-15 16:34:03 UTC
(In reply to comment #0)

> (in conjunction with the referenced definitions) suggests that if the new
> attribute name has namespace binding (null, null) and the target element has a
> namespace binding (null, "abc.uri"), then a conflict exists and XUDY0023 is
> raised. However, this situation is clearly not a conflict, in fact, it is
> likely to be very common and no trouble at all.

I don't understand why this is no trouble at all. I think you are talking about cases like this:

insert node attribute role { "agent" }
into <foo xmlns="purple.example.com"/>

If role has no prefix, what namespace should it be in? Should it adopt the namespace associated with an absent prefix in the element where it is inserted? Should it retain whatever namespace it had before insertion? I think either answer can lead to some rather confusing scenarios.

Jonathan
Comment 3 Michael Kay 2008-04-15 16:38:27 UTC
An attribute with no prefix is always in no namespace.
Comment 4 Jonathan Robie 2008-04-16 14:22:07 UTC
(In reply to comment #3)
> An attribute with no prefix is always in no namespace.
> 

Thanks - my synapses were flapping in the breeze.
Comment 5 Don Chamberlin 2008-05-20 23:39:47 UTC
The Query Working Group considered this bug report on 20 May 2008, and agreed to make the change suggested by Michael Kay. In addition to the modified rule in Section 2.4.4 clause 2b, we will add the following new rule to Section 3.1.11 (upd:rename) following rule 1b: "If $newname has no prefix and no namespace URI, the namespaces property of $target is modified by removing the binding (if any) for the empty prefix."

Since the submitter of this bug report has approved this resolution, I am marking this bug report as Closed.

Don Chamberlin (for the Query Working Group)