XSD <any>
Element
The <any>
element allows us to extend an XML document with elements not specified in the schema!
<any>
Element
The <any>
element allows us to extend an XML document with elements not specified in the schema!
The following example is an excerpt from an XML schema named "family.xsd". It shows a declaration for the "person" element. By using the <any>
element, we can extend the content of "person" with any elements (after <lastname>
):
Now, we want to extend the "person" element with the "children" element. In this case, we can do so even though the author of the schema did not declare any "children" elements.
Take a look at this schema file, named "children.xsd":
The following XML file (named "Myfamily.xml") uses components from two different schemas, "family.xsd" and "children.xsd":
This XML file is valid because the schema "family.xsd" allows us to extend the "person" element with optional elements after the "lastname" element.
Both <any>
and <anyAttribute>
can be used to create extensible documents! They allow documents to include additional elements not declared in the main XML schema.