Databases Reference
In-Depth Information
However, if we chose to use qualified elements, our XML instance would now
appear as shown in the following code snippet:
<cmn:addressxmlns:cmn="http://rubiconred.com/obay/xsd/common">
<cmn:addressLine1>7PineDrive</cmn:addressLine1>
<cmn:addressLine2></cmn:addressLine2>
<cmn:city>Eltham<cmn:city>
<cmn:state>VIC</cmn:state>
<cmn:zip>3088</cmn:zip>
<cmn:country>Australia</cmn:country>
</cmn:address>
With unqualified namespaces, the XML instance loses most of its namespace
declarations and prefixes, resulting in a slimmed down and simpler XML instance
that hides the complexities of how the overall schema is assembled.
The advantage of using qualified namespaces is that you can quickly see
what namespace an element belongs to. As well as removing any ambiguity,
it provides the context in which an element is defined, giving a clearer
understanding of its meaning.
Whichever approach you use, it's important to be consistent, as mixing qualified and
unqualified schemas will produce instance documents where some elements have a
namespace prefix and others don't. This makes it a lot harder to manually create or
validate an instance document, as the author needs to understand all the subtleties of
the schemas involved, making this approach more error-prone.
Another consideration over which approach to use is whether you are using local or
global element declarations, as unqualified namespaces only apply to local elements.
Having a mixture of global elements and local unqualified elements in your schema
definition will again produce instance documents where some elements have a
namespace prefix and others don't, with the same issues mentioned earlier.
A final consideration is whether you are using default namespaces. If you are
then you should use qualified names, as unqualified names and default namespaces
don't mix.
As we recommend, using both global elements (see later for the reason why) and
default namespaces, we would also recommend using qualified namespaces.
Qualified or unqualified attributes
Like elements, XML Schema allows us to choose whether an attribute is qualified or
not. Unless an attribute is global (that is, declared a child of schema and thus can be
used in multiple elements), there is no point in qualifying it.
 
Search WWH ::




Custom Search