Re: Restriction based on attribute value

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 UTC