Kofi Sarfo
Kofi Sarfo

Reputation: 3360

Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?

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?

Upvotes: 1

Views: 454

Answers (1)

Chris Lercher
Chris Lercher

Reputation: 37798

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 :-)

Upvotes: 2

Related Questions