IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

recursive element in XSD schema Options · View
vjedlicka
Posted: Wednesday, December 28, 2016 8:52:08 PM
Rank: Newbie

Joined: 12/28/2016
Posts: 1
I am trying to create a schema for a drawing.

The root element is "document".
It contains one tag named "layers".
"layers" contains several "layer".
"layer" contains several "symbol"
"symbol" contains "layers"

How can I make the "layers" element recursive?

Thanks
Vaclav
island
Posted: Thursday, December 29, 2016 4:56:49 AM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
Declare "layers" as a global element in your schema (top level) and then reference it:

Code:


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="document">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="layers"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="layers">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="layer">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="symbol">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element ref="layers" minOccurs="0"/>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.