Some notes about DOMException

Hi,
In DOM-Level-2-Core, Document::createAttributeNS raises the following
exception:
  DOMException.NAMESPACE_ERR: Raised if the qualifiedName is malformed, if
the qualifiedName has a prefix and the namespaceURI is null, if the
qualifiedName has a prefix that is "xml" and the namespaceURI is different
from "http://www.w3.org/XML/1998/namespace", or if the qualifiedName is
"xmlns" and the namespaceURI is different from
"http://www.w3.org/2000/xmlns/".

 · Shouldn't it also be raised if the qualifiedName has a prefix that is
"xmlns" and the namespaceURI is different from
"http://www.w3.org/2000/xmlns/" ? as it is said in "1.1.8. XML Namespaces":
Note: In the DOM, all namespace declaration attributes are by definition
bound to the namespace URI: "http://www.w3.org/2000/xmlns/". These are the
attributes whose namespace prefix or qualified name is "xmlns".

 · And what happens if the qualifiedName has a prefix different from
"xmlns", or has no prefix and a local name different from "xmlns", and the
namespaceURI is "http://www.w3.org/2000/xmlns/" ?
for example aDocument.createAttributeNS("http://www.w3.org/2000/xmlns/",
"prefix:localName") or aDocument.createAttributeNS("http://www.w3.org/2000/xmlns/",
"localNameOnly")

Same question about the "xml" prefix and the
"http://www.w3.org/XML/1998/namespace" namespace URI.
This also applies to any create*() method of Document and
DOMImplementation.

 · What about namespace declarations bounding prefixes beginning with "xml"
in any case combination ?
They are illegal in [XML Namespaces].

These 3 notes also apply to Element.setAttributeNS()

I propose the following reformulation:
DOMException.NAMESPACE_ERR: Raised if the qualifiedName is malformed, if
the qualifiedName has a prefix and the namespaceURI is null, if the
qualifiedName has a prefix that is "xml" and the namespaceURI is different
from "http://www.w3.org/XML/1998/namespace", if the qualifiedName has a
prefix different from "xml" and the namespaceURI is
"http://www.w3.org/XML/1998/namespace", if the qualifiedName has a prefix
that is "xmlns" or is "xmlns" and the namespaceURI is different from
"http://www.w3.org/2000/xmlns/", if the qualifiedName has a prefix
different from "xmlns" or isn't equal to "xmlns" and the namespaceURI is
"http://www.w3.org/2000/xmlns/", or if the qualifiedName has a prefix that
is "xmlns" and a local name that begins with the 3-letter sequence x, m, l
in any case combination.

-----

DOMException.INVALID_CHARACTER_ERR is defined as follow:
  If an invalid or illegal character is specified, such as in a name. See
production 2 in the XML specification for the definition of a legal
character, and production 5 for the definition of a legal name character.

What about qualifiedNames beginning with "xml" in any case combination?
They are reserved for W3C use (allowed ones are xml:base, xml:space,
xml:lang, xmlns and xml-stylesheet for the moment).
Does a DOM implementation have to know allowed qualifiedNames ? Is this
defined by the DOM spec. or implementation-dependant ?
This applies to any create*() method of Document and DOMImplementation as
well as Element.setAttribute(), Element.setAttributeNS() and Node.prefix
(on setting); and maybe others I forgot.

Thanks in advance for any enlightenment.

Tom.

Received on Monday, 29 January 2001 09:13:56 UTC