1.1. Xdefinition and model of XML element
As a starting point, consider following XML element that describes a book:
<Book ISBN = "123456789"
published = "2010" >
title = "Xdefinition tutorial" >
</Book>
XML data can be described, for example, using XSD (XML Schema) or Relax NG.
Xdefinition is
an alternative approach to XML data description. The Xdefinition allows for a more precise and detailed
description of XML data. Let's get a first idea of what an XML element description looks like in
an Xdefinition (this description is called an
element model).
Xdefinition describes the names and cardinality (possible number of occurrences) of items and the
structure of children in the XML element model. An Xdefinition itself is an XML
element with the Xdefinition namespace ("b>http://www.xdef.org/xdef/4.2") and local name "def"
where the name prefix referrs to the Xdefinition namespace. The child nodes of an Xdefinition can
be element models.
Note that such a description looks similar to the data it describes, but attribute values (and textual
content of elements) are replaced by value descriptions in this model. The description of data value
contains the
quantifier (specification of occurrence) of the value and the call to the
validation method (analysis and evaluation of the data type).
For example:
required int(10000000, 999999999);
mandatory integer number in range 10000000 ... 999999999
optional gYear();
optional notation of calendar year
required string();
mandatory character sequence
The language used here to describe data values is called
"Xscript" of the X definition.
The element models are written as child nodes of this element.
The Xdefinition with XML data model describing the above book will be of the form:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2">
<Book ISBN = "required int(10000000, 999999999); /* ISBN code - integer number in the given range */"
published = "optional gYear(); /* year of publishing (can be omitted). */"
title = "required string(); /* any string */" >
</Book>;
</xd:def>
Note the possibility to write comments (
/*...*/) in the Xscript.