Validate an element depending on the value of another element

Hey there,

I'm new to xml-schema and have a couple of questions. If someone could point
me in the right direction I'd be grateful.

1. If I have a section of XML where one value has a different set of valid
entries depending on another is this possible to cover in xml-schema e.g.

<property>
	<type>1</type>
	<subtype>3</subtype>
</property>

If <type> is one, then <subtype> valid entries are 1, 2 and 3, but if <type>
is two, then <subtype> valid entries are 5, 6 and 7.

2.(I think this one may be due to badly formed XML). Can I use an attribute
from an element to validate child elements in different ways e.g.

<item class="person">
	<name>brian</name>
	<age>7</age>
</item>

is valid but so is

<item class="car">
	<reg>ABC 123</reg>
	<type>saloon</type>
	<manufacturer>BMW</manufacturer>
</item>

Any help much appreciated

Toby

Received on Thursday, 25 September 2003 09:32:33 UTC