<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.java2java.com/namespaces/employee"
xmlns="http://www.java2java.com/namespaces/employee"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xsd:element name="employee">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="email" type="xsd:string"/>
<xsd:element name="hireDate" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="dept" type="xsd:string"/>
<xsd:attribute name="client" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
We have set both attributes to qualified; therefore, all elements and attributes in our instance document must be qualified:
<em:employee
xmlns:em="http://www.java2java.com/namespaces/employee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.java2java.com/namespaces/employee employee.xsd"
em:dept="programming"
em:client="Smith and Co">
<em:name>Joe Smith</em:name>
<em:email>a@a.com</em:email>
<em:hireDate>2008-10-29</em:hireDate>
</em:employee>
If we set elementFormDefault to qualified and omit attributeFormDefault (its default value is unqualified),
we could use the following document instance:
<em:employee
xmlns:em="http://www.java2java.com/namespaces/employee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.java2java.com/namespaces/employee employee.xsd"
dept="programming"
client="Smith and Co">
<em:name>Joe Smith</em:name>
<em:email>a@a.com</em:email>
<em:hireDate>2008-10-29</em:hireDate>
</em:employee>
|