Venetian Blind Model : Venetian Blind « XML Schema « XML Tutorial






The Venetian Blind Model encourages the use of complexTypes rather than just the declaration of elements. 
The idea behind types and the Venetian Blind Model is analogous to the notion of defining a class and using the class to create an object.

<?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"
           elementFormDefault = "qualified"
           attributeFormDefault = "unqualified">
   
   <xs:element name = "Customer" type = "NameType" />
   
   <xs:complexType name = "NameType">
      <xs:sequence>
         <xs:element name = "FirstName" type = "xs:string" />
         <xs:element name = "MiddleName" type = "xs:string" 
                     minOccurs = "0" maxOccurs = "1" />
         <xs:element name = "LastName" type = "xs:string" />
      </xs:sequence>
      <xs:attribute name = "customerID" type = " xs:integer" 
                    use = "required" />
      <xs:attribute name = "clubCardMember" type = "xs:boolean" />
   </xs:complexType>
   
</xs:schema>


File: Data.xml

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








3.99.Venetian Blind
3.99.1.Venetian Blind Model