W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2009

Re: alternative obligatory attributes

From: Kevin Braun <kbraun@obj-sys.com>
Date: Thu, 12 Mar 2009 13:39:49 -0400
Message-ID: <49B948E5.60009@obj-sys.com>
To: Erwin <Erwin.Kloeck@bayernlb.de>
CC: xmlschema-dev@w3.org
There is no straightforward way to do this that I know of.

Here is an outline of an approach.  I think it would work, but it won't 
help you if you have many such pairs of attributes on the same element.

Define a type for the element, TypeBase.  Make it abstract to force use 
of one of the derived types you are going to define.
Define an extension of TypeBase with the one attribute.
Define an extension of TypeBase with the other attribute.
Declare your element to be of TypeBase.
Use xsi:type in the instance to specify which of the derived types is 
being used.  OR, use a substitution group (but that will mean using 
global elements).

HTH,
Kevin

On 3/12/2009 1:06 PM, Klöck wrote:
>
> Hi,
>
> is it possible to define alternative obligatory attributes for an 
> element? What I want is something like the following,
> where the element otto must have either of two attributes but not 
> both. If it is possible, how would one do this?
>
> <top>
>         <file uri="xxxx"/>
>         <file relative-path="yyyy"/>
> </top>
>
> Thank you for your interest.
>
>
> *Erwin Klöck*
>    Bayerische Landesbank
>    Geschäftsbereich Financial Office, IT and Operations
>    Organisation & Informatik
>    Team Banksteuerung Finance -4493-
>    Brienner Straße 24R/
> /   D-80333 München
>    Telefon: +49 89 / 2171-21420
>    Telefax: +49 89 / 2171-27546
>    _mailto:erwin.kloeck@bayernlb.de_
>    Internet: _http://www.bayernlb.de_
>
>    HRA München 76030; Sitz: München
>
>
>
Received on Thursday, 12 March 2009 17:41:45 GMT

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