XSD Mixed Content

The attributes, elements, and text can be included in a mixed complex type element.

Complex Types with Mixed Content:

Example:


 Dear Ms. Vigesa.
 You ranked 10
 in the exam conducted on 2020-06-10.

Schema:


  
    
      
      
      
    
  

Explanation:

In the above example, we are defining an XML element, “letter”, that contains both text and other elements. We have also created a schema to declare the “letter” element. The mixed attribute must be set to “true”, for enabling the character data to appear between the child-elements of “letter”. For the elements defined (name, orderid and shipdate) to appear in an order inside a “letter” element, we are using the <xs:sequence> tag.

Example 2:




  
    
    
    
  

Explanation:

In the above example, we are giving the complexType element a name. Here, the “letter” element has a type attribute that refers to the name of the complexType. Several elements can refer to the same complex type, by using this method.

Please follow and like us:
Content Protection by DMCA.com