Is this the complete list of ways to create recursion in XML Schemas?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is this the complete list of ways to create recursion in XML Schemas?

Costello, Roger L.
Hi Folks,

One way to create recursion in XML Schemas is with a recursive element reference, e.g.,

    <xsd:element name="Section" type="SectionType" />
   
    <xsd:complexType name="SectionType">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string" />
            <xsd:element ref="Section"  minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
   

A second way to create recursion in XML Schemas is with a recursive complexType reference, e.g.,

    <xsd:element name="Section" type="SectionType" />
   
    <xsd:complexType name="SectionType">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string" />
            <xsd:element name="Section" type="SectionType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>


A third way to create recursion in XML Schemas is with a recursive include reference, e.g.,

-------------------------
        A.xsd
-------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   
    <xs:include schemaLocation="B.xsd" />

</xs:schema>

-------------------------
        B.xsd
-------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   
    <xs:include schemaLocation="A.xsd" />

</xs:schema>


Is that the complete list? Are there any other ways to create recursion in XML Schemas?

/Roger

Reply | Threaded
Open this post in threaded view
|

Re: Is this the complete list of ways to create recursion in XML Schemas?

Liam R. E. Quin
On Sat, 2012-08-25 at 15:10 +0000, Costello, Roger L. wrote:
> Hi Folks,

> Is that the complete list? Are there any other ways to create
> recursion in XML Schemas?

Some others:

Indirect recursion - element A contains B which can contain A...

Recursion via substitution groups

Co-occurrence can quickly become co-dependency: you can make mutual
dependencies with id/idref for example.

Liam

--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Co-author, "Head First Namespaces", due out 1st April 2013


Reply | Threaded
Open this post in threaded view
|

RE: Is this the complete list of ways to create recursion in XML Schemas?

Costello, Roger L.
Thanks Liam.

> Recursion via substitution groups

Here is an example of circular substitutionGroups:

    <xsd:element name="Subway" substitutionGroup="Metro" type="xsd:string" />
   
    <xsd:element name="Metro" substitutionGroup="Subway" type="xsd:string" />

However, when I validated this schema I got an error, saying circular substitutionGroups are not allowed.

Is that correct, circular substitutionGroups are not allowed?

/Roger


-----Original Message-----
From: Liam R E Quin [mailto:[hidden email]]
Sent: Saturday, August 25, 2012 3:24 PM
To: Costello, Roger L.
Cc: [hidden email]
Subject: Re: Is this the complete list of ways to create recursion in XML Schemas?

On Sat, 2012-08-25 at 15:10 +0000, Costello, Roger L. wrote:
> Hi Folks,

> Is that the complete list? Are there any other ways to create
> recursion in XML Schemas?

Some others:

Indirect recursion - element A contains B which can contain A...

Recursion via substitution groups

Co-occurrence can quickly become co-dependency: you can make mutual
dependencies with id/idref for example.

Liam

--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml
Co-author, "Head First Namespaces", due out 1st April 2013