开发者

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

开发者 https://www.devze.com 2022-12-23 16:51 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号