Re: Namespace undeclarations in 1.1

> Does the construct xmlns:p="" make p be "out of scope", so any reference to
> p is an error, or does it make p refer to the non-namespace, in the same way
> as xmlns="" makes the default prefix refer to the non-namespace?

The former.

> But what replaces this previous association?

Given:

  <foo>
    <bar xmlns:p="xxx">
       <fum xmlns:p="">
          ...

Inside <bar> but outside <fum> there is an association of p with xxx.
Outside <bar>, and inside <fum>, p is not associated with a namespace
and it is a namespace well-formedness error to use it as a prefix.

> Further (and this really is strange), reading section 7 (Conformance), it
> says that a document to be well-formed must match the "Namespace
> Constraints" (in quotes). But the "namespace constraints" are nowhere
> defined, so this gives no further clues.

???  The namespace constraints are constraints on productions, like
the well-formedness and validity constraints in the XML spec.  They are
given in sections labelled "Namespace constraint:".  In Namespaces 1.1
there are only two of them: "Reserved Prefixes and Namespace Names"
and "Prefix Declared".

The second of these seems to unambiguously answer your main question:

  Namespace constraint: Prefix Declared

  The namespace prefix, unless it is xml or xmlns, MUST have been
  declared in a namespace declaration attribute in either the
  start-tag of the element where the prefix is used or in an ancestor
  element (i.e. an element in whose content the prefixed markup
  occurs). Furthermore, the attribute value in the innermost such
  declaration MUST NOT be an empty string.

So 

  <foo>
    <bar xmlns:p="xxx">
      <fum xmlns:p="">
        <p:fie/>

violates the constraint, because the innermost namespace declaration
attribute for p is an empty string.

> It would be very useful to be able to refer to the non-namespace using an
> explicit prefix

True.  There are three things a prefix or non-prefix can mean: some
namespace, no namespace, or an error; and only two syntaxes: a URI
or the empty string.

                    prefix         no-prefix

    namespace       xmlns:p="xxx"  xmlns="xxx"

    no-namespace        *          xmlns=""

    error           xmlns:p=""        *

XML 1.1 introduces the xmlns:p="" possibility; there is no syntax for
the cases marked "*".  The inconsistency of meaning of xmlns="" and
xmlns:p="" matches the different status of prefixes and no-prefix at
the start of a document.

> especially in a context like XSLT

XSLT was one of the uses people had in mind when they argued for
prefix undeclaring, but they were thinking of cases like

    <xsl:copy>
      <bar/>
    </xsl:copy>

which can't be accurately serialized in XML 1.0 if the copied node
has namespace bindings which <bar/> doesn't.

-- Richard

Received on Monday, 11 October 2004 22:49:10 UTC