Re: Several same elements

Hi Cyrill,

> Is it possible to have an xml struktur like below, or do you have any 
> better ideas to solve such a structure? 

Sure.

> <chapter id=""><!-- chapter name -->
>    <chapter id=" "><!-- chapter name --></chapter>
>    <chapter id=" "></chapter>
>    <chapter id=" ">
>        <chapter id=" "></chapter>
>    </chapter>
> </chapter>
>
> If it would be possible how could i describe this in xml-schema? The 
> way I first thought its actually not THE solution. I'm looking for an 
> short and simple possibility to solve this problem. 

What you need is a recursive content model and this can be expressed 
like this:

<xsd:element name="chapter" type="chapterType"/>

<xsd:complexType name="chapterType">
    <xsd:sequence>
        <xsd:element name="chapter" type="chapterType" minOccurs="0" 
maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="idcheck"/>
</xsd:complexType>

However, if you do it this way you can't control the number of chapter 
elements that can appear on each level. If you need to do this you have 
to specify one complexType for each level. Also, note that you must have 
minOccurs="0" on the "inner" chapter element otherwise you'll get an 
infinite content model that parsers can't handle.

Cheers,
/Eddie

Received on Monday, 19 August 2002 20:16:10 UTC