Page 1 of 1

Circular References Inside a Schema

Posted: Wed Nov 08, 2006 4:47 pm
by Daniel
Hi,

I need help with a XMLBeans based App that I'm developing for a client. My client right now stores his info in some
XML's which he currently uses in a .NET based App :

Code: Select all

<company>
<division>
<manager/>
<email/>
<subdivisions>
<division>
...
</division>
</subdivisions>
<division>
</company
I'm trying to create a XSD for that structure, however I'm stuck with the division reference inside the subdivisions. Is there any way to support this "circular" reference in XSD [/code]

Posted: Thu Nov 09, 2006 12:44 am
by george
There is no problem to express such a structure in XML Schema. oXygen can generate an XML schema automatically from your sample file, for instance using the "Convert to" action and selecting XML Schema oXygen gives the following schema file that validates your XML sample:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="company" type="division"/>
<xs:complexType name="division">
<xs:sequence>
<xs:element ref="division"/>
</xs:sequence>
</xs:complexType>
<xs:element name="division">
<xs:complexType mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="email"/>
<xs:element ref="manager"/>
<xs:element ref="subdivisions"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="email">
<xs:complexType/>
</xs:element>
<xs:element name="manager">
<xs:complexType/>
</xs:element>
<xs:element name="subdivisions" type="division"/>
</xs:schema>
Best Regards,
George