Mega Code Archive

 
Categories / XML / XML Schema
 

Requiring All Elements and Attributes Be Qualified

<?xml version = "1.0" ?>  <schema xmlns = "http://www.w3.org/2001/XMLSchema"         targetNamespace = "http://www.rntsoft.com/employees"         xmlns:cust = "http://www.rntsoft.com/employees"         elementFormDefault = "qualified"         attributeFormDefault = "qualified">        <element name = "employee" type = "cust:employeeType" />        <complexType name = "employeeType">       <sequence>          <element name = "FirstName" type = "string" />          <element name = "MiddleInitial" type = "string" />          <element ref = "cust:LastName" />       </sequence>       <attribute name = "clubCardMember" type = "boolean" />       <attribute ref = "cust:employeeID" />    </complexType>        <element name = "LastName" type = "string" />    <attribute name = "employeeID" type = "integer" />     </schema> We could qualify each element and attribute individually like so:  <?xml version = "1.0" ?> <cust:employee xmlns:cust = "http://www.rntsoft.com/employees"                cust:clubCardMember = "true"                 cust:employeeID = "24427">    <cust:FirstName>Ray</cust:FirstName>    <cust:MiddleInitial>G</cust:MiddleInitial>    <cust:LastName>Bayliss</cust:LastName> </cust:employee> But the following would NOT be valid: <?xml version = "1.0" ?> <employee xmlns = "http://www.rntsoft.com/employees"           clubCardMember = "true"            employeeID = "24427">    <FirstName>first</FirstName>    <MiddleInitial>middle</MiddleInitial>    <LastName>last</LastName> </employee>