The XML specification says that unqualified namespaces are in no namespace. The semantics in the spec are debatable but all XML toolsets have been authored to work this way. See:
XML Namespaces and Unprefixed Attributes
It's a concept that my subconscious hates for reasons that my conscious brain struggles to articulate.
If unqualified attributes are not in any namespace, then how come validation still works? It's a contradiction.
And what happens when there's two attributes of the same name in scope. One from a default namespace and one belonging to the current element.
<document xmlns="default.ns" xmlns:hr="humanresources.ns">
<hr:user id="abc" />
</document>
If id is defined in both default.ns and humanresources.ns but with different data types, say xs:token and xs:integer which namespace will id be resolved to for validation, if either?
Assuming a validator would error on the ambuiguity and force other attribute(s) to be qualified, then would I have to write a helper GetLocalAttribute method to deal with all this?
Like:
ids= select all attributes on element where localname equalsidb= select single fromidswhere namespace equals element namespace- if
b!= null { returnb} - else return single from
idswhere namespace equals null
Luke