W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2003

Validate an element depending on the value of another element

From: Tobias Bunyan <tobias@findaproperty.com>
Date: Thu, 25 Sep 2003 14:06:22 +0100
Message-ID: <76E3C00CEF9CA34CA85BEEA25837A2F405E69C@hallmark.findaproperty.com>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT