Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > creating recurrent tags in XML Schema

Reply
Thread Tools

creating recurrent tags in XML Schema

 
 
ruthless@poczta.onet.pl
Guest
Posts: n/a
 
      11-29-2003
hello.

i've got a question

can i in XML Schema define tag that works as lists knows from e.g. C,C++ -
recurrent tags?

i'm talking about e.g. genealogical tree every level of this tree is the
same

1) Grandparents // parents for the level 2
2) parenst // parents for the level 3
3) children // parents for the next level

and so on...

can you help me with simple recuretion example?

thanks in advance
greetings R


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.542 / Virus Database: 336 - Release Date: 03-11-18


 
Reply With Quote
 
 
 
 
C. M. Sperberg-McQueen
Guest
Posts: n/a
 
      11-30-2003
"" <ruthless@CUT_THIS.poczta.onet.pl> writes:

> 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
xmlnssd="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"
xmlnssi="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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XHTML Modularization: Creating XML schema for mixed custom tags andXHTML mk189@seznam.cz XML 0 05-09-2008 12:14 PM
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Recurrent issue with Trillian ~ Computer Support 1 10-21-2003 01:44 AM
Re: Recurrent issue with Trillian [SOLVED] ~ Computer Support 0 10-19-2003 06:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57