Databases Reference
In-Depth Information
Qualified or unqualified element names
When constructing an XML instance based on an XML Schema, we have the option
as the schema designer to decide whether each element should be qualified, that is,
have a prefix that identifies the namespace of where the element is defined, or have
no prefix, that is, it is unqualified and the origin of the namespace is hidden within
the instance.
The approach you take is often a question of style. However, each has its own
advantages and disadvantages, particularly when you create XML instances that
are defined across multiple namespaces. Take the schema definition for the element
<address> , as shown in the following code snippet:
<xsd:schemaxmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://rubiconred.com/obay/xsd/common"
targetNamespace="http://rubiconred.com/obay/xsd/common"
elementFormDefault="qualified or unqualified">
<xsd:elementname="address"type="tAddress"/>
<xsd:complexTypename="tAddress">
<xsd:sequence>
<xsd:elementname="addressLine1"type="xsd:string"/>
<xsd:elementname="addressLine2"type="xsd:string"/>
<xsd:elementname="city"type="xsd:string"/>
<xsd:elementname="state"type="xsd:string"/>
<xsd:elementname="zip"type="xsd:string"/>
<xsd:elementname="country"type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
If we chose unqualified elements, then an instance of this schema would look as
shown in the following code snippet:
<cmn:addressxmlns:cmn="http://rubiconred.com/obay/xsd/common">
<addressLine1>7PineDrive</addressLine1>
<addressLine2></addressLine2>
<city>Eltham<city>
<state>VIC</state>
<zip>3088</zip>
<country>Australia</country>
</cmn:address>
 
Search WWH ::




Custom Search