W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2004

Re: Restriction based on attribute value

From: Xan Gregg <xan.gregg@jmp.com>
Date: Mon, 3 May 2004 10:28:21 -0400
Message-Id: <20C96443-9D0E-11D8-812F-000393BB384C@jmp.com>
Cc: <xmlschema-dev@w3.org>
To: <richard.liu@ubs.com>

There's no general way for the value of an attribute to constrain the 
element content in XML Schema, except for one special attribute, 
"xsi:type".  I think you can achieve the effect you are looking for 
with xsi:type by making separate type definitions for the various cases 
like "viewing-800".

If xsi:type seems too unnatural for your application, you might try a 
tool called schematron, which allows you to specify additional schema 
constraints in a separate document.

xan

On May 3, 2004, at 6:58 AM, <richard.liu@ubs.com> wrote:
> My schema defines an element images consisting of child elements 
> image.  Each image has an attribute context, an enumeration of 
> "viewing", "viewing-1024", "viewing-800", "printing".  I would like to 
> define a new type of images based on images.  The new type must have 
> at least two image child elements, one with context="viewing-1024" and 
> one with context="viewing-800".  How can I do this, perhaps by 
> restricting the original images?
>
> Thanks,
> Richard R. Liu
Received on Monday, 3 May 2004 10:28:48 GMT

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