Looking Behind Namespace Qualification : targetNamespace « XML Schema « XML






Looking Behind Namespace Qualification


File: Schema.xsd

<?xml version = "1.0" ?> 
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"
           targetNamespace = "http://www.java2s.com/Customers"
           xmlns = "http://www.java2s.com/Customers">
   
   <xs:element name = "Customer" type = "CustomerType" />
   <xs:complexType name = "CustomerType">
      <xs:sequence>
         <xs:element name = "FirstName" type = "xs:string" />

         <xs:element name = "MiddleInitial" type = "xs:string" />
         <xs:element ref = "LastName" />
      </xs:sequence>
      <xs:attribute name = "clubCardMember" type = "xs:boolean" />
      <xs:attribute ref = "customerID" />
   </xs:complexType>
   <xs:element name = "LastName" type = "xs:string" />
   <xs:attribute name = "customerID" type = "xs:integer" />
   
</xs:schema>

File: Data.xml

<?xml version = "1.0" ?>
<cust:Customer xmlns:cust = "http://www.java2s.com/Customers"
               clubCardMember = "true" 
               cust:customerID = "24427">
   <FirstName>first</FirstName>
   <MiddleInitial>middle</MiddleInitial>
   <cust:LastName>last</cust:LastName>
</cust:Customer>

 








Related examples in the same category

1.Set targetNamespace
2.targetNamespace and non-default namespace
3.Creating Vocabularies that Do Not Belong to a Namespace
4.Creating Vocabularies that Belong to a Namespace