XSD any Element

To extend the XML document with elements not specified by the schema, the <any> element is used.

The <any> Element:

To make EXTENSIBLE documents, i.e., to allow documents to contain additional elements that are not declared in the main XML schema, the <any> and <anyAttribute> elements are used.

Example:


  
    
      
      
      
    
  

Explanation:

In the above example, we are displaying a fragment from an XML schema called “friend.xsd”, declaring the “student” element. The content of “student” with any element can be extended after <lastname> by using the <any> element.

sibling.xsd:





  
    
      
    
  



Explanation:

In the above example, we are extending the “student” element with a “sibling” element, even if the author of the schema above never declared any “sibling” element.

Myfriend.xml:






  Tom
  Jonas
  
    Jack
  



  John
  Davis



Explanation:

In the above example, we are creating the “Myfriend.xml” file to use the components from two different schemas; “friend.xsd” and “sibling.xsd”. Now, since the schema “friend.xsd” allows us to extend the “student” element with an optional element after the “lastname” element, the XML file Myfriend.xml is valid.

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