Re: Attribute type in XMLSchema

Hi Stamatis,

> Hello. I am a beginner in XML Schema and I have a question. I want
> to set an attribute to be of type either xsd:string or xsd:int
> or...or...e.t.c Can I use somehow the Choice indicator in the
> attribute declaration?

You can create a union type of all the types that you want to allow.
Note that you should arrange the member types in an order so that the
most specific type is first -- if you put xs:string first then all the
attributes will be counted as being strings because all attribute
values are in the lexical space of xs:string.

Try:

<xs:attribute name="foo" type="manyTypes" />

<xs:simpleType name="manyTypes">
  <xs:union memberTypes="xs:int xs:string" />
</xs:simpleType>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 27 June 2003 05:56:51 UTC