can i in XML Schema define tag that works as lists knows from e.g. C,C++ -
recurrent tags?
You can certainly define recursive elements types in XML
Schema.
can you help me with simple recuretion example?
Sure. Here is a simple schema for documents with titles,
paragraphs, and sections (tagged 'doc', 'title', 'p', and
'div'), in which sections are recursive (i.e. 'div' elements
can contain 'div' elements).
<xsd:schema
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns="
http://example.com/simple-recursive-example"
targetNamespace="
http://example.com/simple-recursive-example" >
<xsd:element name="doc" type="T-div"/>
<xsd:element name="div" type="T-div"/>
<xsd:element name="p"/>
<xsd:element name="title"/>
<xsd:complexType name="T-div">
<xsd:sequence>
<xsd:element ref="title"/>
<xsd:element ref="p" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="div" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Here is a document using that schema:
<my:doc xmlns:my="
http://example.com/simple-recursive-example"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
="
http://example.com/simple-recursive-example ruthless.xsd">
<my:title>Simple document showing recursion</my:title>
<my
>This document illustrates the 'simple recursive example' schema.</my
>
<my
>The same structure is used for the 'doc' and the 'div' elements,
and the definition of the 'div' element is recursive: 'div' elements
can nest within 'div' elements. </my
>
<my:div>
<my:title>The 'document' element</my:title>
<my
>The document contains a title, a series of paragraphs,
and a series of 'div' elements.</my
>
</my:div>
<my:div>
<my:title>The 'div' element</my:title>
<my
>Like the 'doc' element, any 'div' element can
contain a title (required),
a series of zero or more paragraphs,
and a series of zero or more 'div' elements.</my
>
<my:div>
<my:title>The parallel between doc and div</my:title>
<my
>The identity of structure between 'doc' and 'div' elements
is captured in the schema by using the same complex type
(T-div) for both the 'doc' element and the 'div' element.</my
>
</my:div>
<my:div>
<my:title>The <my:title>recursion</my:title></my:title>
<my
>The ability of 'div' elements to contain other 'div' elements
is expressed in the schema by the simple expedient of naming
the 'div' element as a possible child of the 'div' element.</my
>
</my:div>
</my:div>
</my:doc>
Note that because they are implicitly declared as having the ur-type
(type xsd:anyType), the 'title' and 'p' elements can also self-nest,
as illustrated in the last 'my:title' element.
I hope this helps.
-C. M. Sperberg-McQueen
World Wide Web Consortium