|Two Types of XML Schema Language||
XML schema languages come in two types:
This paper discusses which schema language is appropriate for a specific purpose.
Definition: A grammar-based schema language specifies the structure and contents of elements and attributes in an XML instance document. For example, a grammar-based schema language can specify the presence and order of elements in an XML instance document, the number of occurrences of each element, and the contents and datatype of each element and attribute.
Definition: A rule-based schema language specifies the relationships that must hold between the elements and attributes in an XML instance document. For example, a rule-based schema language can specify that the value of certain elements must conform to a rule or algorithm.
Example: The following XML instance document contains a classification attribute on the <Document> element and on the <Para> element:
A grammar-based schema language can be used to specify, for example:
A rule-based schema language can be used to specify, for example:
The above examples illustrate that a grammar-based schema specifies syntax and a rule-based schema specifies business rules on the data. Neither schema specifies semantics.
To constrain the structure, form, or syntax of XML instance documents, use a grammar-based schema language.
To specify data relationships, use a rule-based schema language
In some cases, both types of schema language might be necessary.