[Bug 4463] [XQuery] Missing rules for misuse of the xmlns namespace

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4463





------- Comment #3 from mike@saxonica.com  2007-08-01 20:33 -------
I have a feeling this can be done a bit more declaratively, by defining
constraints on the static context and the in-scope namespaces of a dynamically
constructed element. This reduces the number of places we need to state the
rules, and reduces the risk of missing one.

I've also changed the proposal so that using "xmlns" as a prefix in an element
or attribute name is a conflict rather than an error, and results in a
different prefix being substituted in the same way as for other prefix
conflicts. This is (a) because that's what XSLT does, and (b) because I think
you can read the current spec this way.

I've also changed it, to align with the rule in XML and avoid unnecessary
changes to the current spec, so that it's not an error to create an explicit
binding of the prefix xml to the XML namespace (it's just redundant).

Of course, the editor is welcome to add notes or cross-references to draw
attention to these rules in other places where appropriate. The main such case
is in attribute constructors, where users will try to create namespace
declarations by pretending they are attributes.

(a) In 2.1.1 Static Context, Statically known namespaces, add the rule "The
statically known namespaces will never contain two bindings for the same
prefix. They will always include a binding of the prefix xml to the namespace
http://www.w3.org/XML/1998/namespace, and will never bind any other prefix to
that namespace. They will never include a binding for the prefix xmlns or for
the namespace http://www.w3.org/2000/xmlns/, and any attempt to create such a
binding is a static error [err:XQST0070].

(b) In 3.7.4, fourth bullet, after the first sentence, "For each namespace used
in the name of the constructed element or in the names of its attributes, a
namespace binding must exist." add "It is a dynamic error if this would require
creation of a binding for the namespace http://www.w3.org/2000/xmlns/
[err:XQDY0074]." After "If this would result in a conflict, because it would
require two different bindings of the same prefix" add ", or because it would
require a binding of the prefix xmlns, or a binding of a prefix other than xml
to the namespace http://www.w3.org/XML/1998/namespace, or a binding of a
namespace other than http://www.w3.org/XML/1998/namespace to the prefix xml, " 

(c) 3.7.1.2 Namespace Declaration Attributes, bullet 3, says "It is a static
error [err:XQST0070] if a namespace declaration attribute binds a namespace URI
to the predefined prefix xmlns". We can now drop this, it is incomplete and is
subsumed by (a) above.

(d) In Section 3.7.3.2, Computed Attribute Constructors:
Old Text:
The node-name property of the constructed attribute (an expanded QName)
is checked as follows: If its URI part is http://www.w3.org/2000/xmlns/
(corresponding to namespace prefix xmlns) or if it is in no namespace and
its local name is xmlns, a dynamic error [err:XQDY0044] is raised.
Replacement Text:
The node-name property of the constructed attribute (an expanded QName)
is checked as follows: If it is in no namespace and its local name is xmlns, a
dynamic error [err:XQDY0044] is raised.
[: the other condition is now covered by (b) :]

(e) In Section 4.12, Namespace Declaration:
At the end of the paragraph that begins with "The namespace prefix" and
ends with [err:XQST0033], delete the phrase "must not be xml or xmlns
[err:XQST0070], and" (it's now covered by (a) above).

(f) In Section 4.12, Namespace Declaration:
In the paragraph that begins with "XQuery has several predeclared namespace
prefixes", change the parenthesized text as follows:
Delete the parenthetical text:
"(however, the prefix xml may not be redeclared, and no other prefix may
be bound to the namespace URI associated with the prefix xml [err:XQST0070])".
(it's covered by (a) above)

(g) Change to text of error code XQDY0044:
Old text:
It is a dynamic error if the node-name property of the node constructed by
a computed attribute constructor is in the namespace
http://www.w3.org/2000/xmlns/
(corresponding to the namespace prefix xmlns), or is in no namespace and has
local name xmlns.
Replacement text:
It is a dynamic error if the node-name of the node constructed by a computed
element or attribute constructor has the namespace URI 
http://www.w3.org/2000/xmlns/. It is also a dynamic error if the node-name of
the attribute node constructed by a computed attribute constructor has no
namespace prefix and has the local name
xmlns.

(f) Change to text of error code XQST0070:
Old text:
A static error is raised if a namespace URI is bound to the predefined prefix
xmlns, or if a namespace URI other than http://www.w3.org/XML/1998/namespace
is bound to the prefix xml, or if the prefix xml is bound to a namespace URI
other than http://www.w3.org/XML/1998/namespace.
Replacement text:
A static error is raised if a namespace URI is bound to the predefined prefix
xmlns, or if a prefix is bound to the namespace URI
http://www.w3.org/2000/xmlns/,
or if a namespace URI other than http://www.w3.org/XML/1998/namespace
is bound to the prefix xml, or if the prefix xml is bound to a namespace URI
other than http://www.w3.org/XML/1998/namespace.

Received on Wednesday, 1 August 2007 20:33:36 UTC