Circular References Inside a Schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
Daniel
Posts: 2
Joined: Tue Jul 11, 2006 12:07 am

Circular References Inside a Schema

Post 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]
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post 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
George Cristian Bina
Post Reply