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 a开发者_StackOverflow社区nd accept either.
Is it possible to use an OR operator somehow? What are the options?
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 :-)
精彩评论