tags:

views:

29

answers:

1

I've some XML being returned from various sources and rather than update each of the sources so that they return date-specific data as attributes in either xs:date or xs:dateTime format I'd like for the XML Schema to be liberal and accept either.

Is it possible to use an OR operator somehow? What are the options?

+1  A: 

I think it should work with Union Types: http://www.w3.org/TR/xmlschema-0/#UnionDt

Declare a new type, e.g.:

<xsd:simpleType name="dateOrDateTime">
     <xsd:union memberTypes="xs:date xs:dateTime"/>
</xsd:simpleType>

Then use that type for your attribute. I wish I could try it right now - please report back, if it works :-)

Chris Lercher
Replaced unit with union and it worked just as you thought. Thanks.
Kofi Sarfo
I also corrected it in my snippet above now.
Chris Lercher