tags:

views:

140

answers:

1

Is an empty xml namespace is a valid value. If yes what does it means?

I have XML which looks like following one but I'm not sure what namespace Field1 and Field2 belong to.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  <soapenv:Header />
  <soap:Body>
    <Root xmlns="uri">
      <Field1 xmlns="">147079737</Field1>
      <Field2 xmlns="">POL</Field2>
    </Root>
  </soap:Body>
</soapenv:Envelope>
+7  A: 

Yes, it is valid. Section 6.2 in the Namespaces in XML 1.0 Recommendation specifically says:

The attribute value in a default namespace declaration MAY be empty. This has the same effect, within the scope of the declaration, of there being no default namespace.

Frerich Raabe
But is the above a *default* namespace declaration ?
Brian Agnew
@Brian: Yes; see Definition 3 in Section 3 in the 'Namespace in XML 1.0 Recommendation' I linked in my answer. It says '[Definition: If the attribute name matches DefaultAttName, then the namespace name in the attribute value is that of the default namespace in the scope of the element to which the declaration is attached.]'. DefaultAttName is defined to be 'xmlns'.
Frerich Raabe
In my case if it's the same as having no namespace then what namespace is it? Does XML have a predefined default namespace, the one that is used then there is no default namespace provided by user like in my case?
Sergej Andrejev