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 4487 - [DM] Missing constraint for attribute names
Summary: [DM] Missing constraint for attribute names
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Data Model 1.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Anders Berglund
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-23 21:28 UTC by Michael Kay
Modified: 2008-08-13 18:50 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2007-04-23 21:28:08 UTC
Nowhere does XDM state the following constraint, which is necessary to ensure that an XDM document can be serialized as namespace-well-formed XML.

Add the following either to the numbered list in 6.3.1 (Attribute Nodes/Overview), or to the bulleted list in 3.3.3 (QNames and NOTATIONs), or both, at editor's discretion: 

* In the node-name of an attribute node, if a namespace URI is present then a prefix must also be present.

See also bug #4443. This bug is raised in response to action A-327-04.
Comment 1 John Snelson 2007-04-27 10:02:28 UTC
I don't understand why this situation is any different to having an attribute with a namespace prefix that cannot be used since the prefix is already bound on the same element to a different namespace URI. In both cases the XDM shouldn't care, because the prefix is irrelevant to the actual name of the attribute (the namespace URI/local name pair).

In my opinion this situation is a serialisation issue, and should be dealt with during serialisation. I think the obvious solution is to make up a namespace prefix for the attribute in both cases - but an alternative solution is to raise an error.
Comment 2 Michael Kay 2007-04-27 10:22:54 UTC
Namespace fixup is not the responsibility of the serializer: the XDM model contains the tree structure *after* fixup has been applied. This enables anyone accessing an XDM tree to be confident that it will satisfy basic XML rules such as names being valid, and no element having two attributes with the same name. The rule that an attribute in a namespace always has a prefix falls into the same category.

>In both cases the XDM
shouldn't care, because the prefix is irrelevant to the actual name of the
attribute (the namespace URI/local name pair).

The name of the attribute is not a namespace URI/local name pair: it is a triple that also includes a prefix: see section 3.3.3 ("In this Data Model, therefore, the value space for qualified names contains a local-name, an optional namespace URI, and an optional prefix.")

The prefix is ignored when comparing two names, but it is visible to applications via functions such as name(). It's important from a usability perspective that name() applied to a node should return the same string that you see when serializing the node, since it is often used in messages and similar output.
Comment 3 Michael Kay 2007-04-27 11:39:07 UTC
>I don't understand why this situation is any different to having an attribute with a namespace prefix that cannot be used

It isn't any different, that's the whole point. In both cases, namespace fixup should ensure that the data model is correct and consistent. The only difference is that we already have constraints saying that if the attribute has a prefix then the prefix must be in-scope on the containing element; we don't currently have a constraint saying that if it has a URI then it must have a prefix.
Comment 4 Norman Walsh 2007-05-08 14:14:33 UTC
I agree with Mike.
Comment 5 Anders Berglund 2007-11-19 21:33:13 UTC
The WGs decided to accept the proposed solution in the description as the fix
for this bug at the Joint telcon 329 of 2007-05-08.