Bug 4487 - [DM] Missing constraint for attribute names
: [DM] Missing constraint for attribute names
Status: CLOSED FIXED
Product: XPath / XQuery / XSLT
Data Model
: Recommendation
: PC Windows XP
: P2 normal
: ---
Assigned To: Anders Berglund
: Mailing list for public feedback on specs from XSL and XML Query WGs
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2007-04-23 21:28 UTC by Michael Kay
Modified: 2008-08-13 18:50 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.


  翻译: