recursive relationships in xml

K

kosaraju.puneeth

hello,

I need to represent recursive relationship in xml which will be
validated by defined xml schema.

example: check.xml

<a>
<testgroup name="first" result ="pass">
<testgroup name="second">
<test name="OPEN" spec = "0"/>
</testgroup>

<test name="SHORT" spec ="1"/>
</testgroup>

<test name="CLOSE" spec ="1"/>

<testgroup name="third" result ="fail">
<test name="OPEN" spec = "1"/>
</testgroup>

</a>

so i have to write a xml schema which can validate "check.xml"

Thanks in advance.
 
S

Stan Kitsis [MSFT]

See below. You'll need to change attribute types to reflect the values they
can take.

<xs:complexType name="testType">
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="spec" use="required" type="xs:string"/>
</xs:complexType>

<xs:complexType name="testGroupType">
<xs:sequence>
<xs:element name="testgroup" type="testGroupType" minOccurs="0"/>
<xs:element name="test" type="testType" minOccurs="0" />
</xs:sequence>
<xs:attribute name ="name" type="xs:string"/>
<xs:attribute name ="result" type="xs:string"/>
</xs:complexType>

<xs:complexType name="aType">
<xs:choice maxOccurs="unbounded">
<xs:element name="testgroup" type="testGroupType"/>
<xs:element name="test" type="testType"/>
</xs:choice>
</xs:complexType>

<xs:element name="a" type="aType"/>

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top