XSD - Complex Mix Element

Complex Mix Element può avere testo, attributi ed elementi. Vedere il seguente esempio:

<student rollno = "393">
   Dear <firstname>Dinkar</firstname>    
   <lastname>Kad</lastname>
   <nickname>Dinkar</nickname>
   <marks>85</marks>	 
</student>

Possiamo dichiarare tale testo complesso utilizzando i seguenti modi:

Usa misto = vero

Definisci complexType con l'attributo "mixed" impostato su true. L'attributo "misto" consente di avere dati di carattere tra gli elementi.

<xs:complexType name = "StudentType" mixed = "true">
   <xs:sequence>
      <xs:element name = "firstname" type = "xs:string"/>
      <xs:element name = "lastname" type = "xs:string"/>
      <xs:element name = "nickname" type = "xs:string"/>
      <xs:element name = "marks" type="xs:positiveInteger"/>
   </xs:sequence>
   <xs:attribute name = 'rollno' type = 'xs:positiveInteger'/>
</xs:complexType>

<xs:element name = 'student' type = 'StudentType' />

Usa solo ComplexType

Definire un elemento di complexType solo con l'elemento di attributo richiesto.

<xs:element name = 'student'>
   <xs:complexType mixed = "true">
      <xs:sequence>
         <xs:element name = "firstname" type = "xs:string"/>
         <xs:element name = "lastname" type = "xs:string"/>
         <xs:element name = "nickname" type = "xs:string"/>
         <xs:element name = "marks" type = "xs:string"/>
      </xs:sequence>
      <xs:attribute name = 'rollno' type = 'xs:positiveInteger'/>
   </xs:complexType>			  
</xs:element>