β
XML Schema Tutorial
XML Schema TutorialIntroduction to XML SchemasWhy Use XML Schema?How to Use XML SchemaXML schema ElementsXSD Simple ElementsXML Schema AttributesXML Schema Restrictions / FacetsXML Schema Complex ElementsXML Schema Complex Empty ElementsXML Schema Complex Types β Elements OnlyXML Schema Complex Elements β Text OnlyXML Schema Complex Types β Mixed ContentXML Schema IndicatorsXML Schema any ElementXML Schema anyAttribute ElementXML Schema Element SubstitutionXML Schema ExamplesXML Schema String Data TypesXML Schema Date/Time Data TypesXML Schema Numeric Data TypesXML Schema Miscellaneous Data TypesXML EditorsXML Schema SummaryXML Schema Reference Manual
XML Schema anyAttribute Element
XML Schema Examples
Deep Dive
- Programming
- Software
- Scripting
- Computer Science
- Search
- Scripting Languages
- Programming Languages
- Web Services
- Development Tools
- Web Services
XSD Element Substitution
With XML Schema, one element can substitute another element.
Element Substitution
Let's illustrate with an example: our users come from the UK and Norway. We want to allow users to choose whether to use Norwegian or English element names in their XML documents.
To solve this problem, we can define a substitutionGroup in the XML schema. First, we declare the head element, then we declare the member elements, which can declare that they are able to substitute the head element.
In the example above, the "name" element is the head element, and the "navn" element can substitute the "name" element.
Consider the following fragment of an XML schema:
A valid XML document (according to the schema above) might look like this:
John Smith
or like this:
John Smith
Preventing Element Substitution
To prevent other elements from substituting a specific element, use the block attribute:
<xs:element name="name" type="xs:string" block="substitu