Qualified Locals

Contact Us or call 1-877-932-8228
Qualified Locals

Qualified Locals

If the elementFormDefault and attributeFormDefault attributes in the xs:schema element are set to "qualified" all locals must be qualified with a prefix.

Code Sample:

Namespaces/Demos/ArtistLocalQualified.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
					xmlns="http://www.webucator.com/Artist"
					targetNamespace="http://www.webucator.com/Artist"
					elementFormDefault="qualified"
					attributeFormDefault="qualified">
	<xs:element name="Artist">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="Name">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Title" type="xs:string"/>
							<xs:element name="FirstName" type="xs:string"/>
							<xs:element name="LastName" type="xs:string"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
			<xs:attribute name="BirthYear" type="xs:gYear" use="required"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

Code Sample:

Namespaces/Demos/MichaelJacksonLocalQualified.xml
<?xml version="1.0"?>
<art:Artist art:BirthYear="1958"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:art="http://www.webucator.com/Artist"
	xsi:schemaLocation=
		"http://www.webucator.com/Artist ArtistLocalQualified.xsd">
	<art:Name>
		<art:Title>Mr.</art:Title>
		<art:FirstName>Michael</art:FirstName>
		<art:LastName>Jackson</art:LastName>
	</art:Name>
</art:Artist>

The result of qualifying all locals is that instance authors do not have to differentiate between local and global declarations. They simply prefix all elements and attributes with a qualifier. This has two major advantages over using unqualified locals.

  • Clarity - it is easy to tell which namespace each element belongs to.
  • Flexibility - the schema author can mix global and local declarations without worrying that the instance author will get confused. As both local and global declarations require prefixes, the instance author doesn't need to know how an element or attribute is declared.
Next