Restrictions on types

  • Thread starter =?ISO-8859-1?Q?Kim_Lok=F8y?=
  • Start date
?

=?ISO-8859-1?Q?Kim_Lok=F8y?=

I have the following class hierarchy / type hierarchy:

A
a
b
c

The xml schema is something like this:

<complexType name="A">
<sequence>
<element minOccurs="1" name="parent" type="A"/>
</sequence>
</complexType>
<complexType name="a">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>
<complexType name="b">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>
<complexType name="c">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>


A is the superclass of a, b and c. A defines a parent that is a pointer
to an instance of one of its subclasses. But there are some
restrictions of what parent can be in the different subclasses. The
following rules apply:

a.parent can be instance of a
b.parent can be instance of a or b
c.parent can be instance of a or b

Is there a way I can capture this in XML Schema? Is there a way to use
enumeration on types?

Thanks
Kim
 
H

Henry S. Thompson

Kim said:
I have the following class hierarchy / type hierarchy:

A
a
b
c

The xml schema is something like this:

<complexType name="A">
<sequence>
<element minOccurs="1" name="parent" type="A"/>
</sequence>
</complexType>

[Minor note -- this accepts only infinite documents -- minOccurs
maybe should be 0 ?]
<complexType name="a">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>
<complexType name="b">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>
<complexType name="c">
<complexContent>
<extension base="A"/>
</complexContent>
</complexType>


A is the superclass of a, b and c. A defines a parent that is a
pointer to an instance of one of its subclasses. But there are some
restrictions of what parent can be in the different subclasses. The
following rules apply:

a.parent can be instance of a
b.parent can be instance of a or b
c.parent can be instance of a or b

Is there a way I can capture this in XML Schema? Is there a way to
use enumeration on types?

I _think_ this would follow if you used restriction instead of
extension, but I can't be sure because I'm not clear what documents
you have in mind -- Is something such as

<root xsi:type='a'>
<parent xsi:type='b'>
<parent xsi:type='c'/>
</parent>
</root>

what you had in mind as OK, but

<root xsi:type='a'>
<parent xsi:type='b'>
<parent xsi:type='a'/>
</parent>
</root>

not OK?

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

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

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top