是否可以编写 XML 模式以允许 xs:date 或 xs:dateTime 的 xs:attribute? [英] Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?

查看:42
本文介绍了是否可以编写 XML 模式以允许 xs:date 或 xs:dateTime 的 xs:attribute?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从各种来源返回了一些 XML,而不是更新每个来源,以便它们返回特定日期的数据作为 xs:date 或 xs:dateTime 格式的属性,我希望 XML 架构能够自由一点,要么接受.

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.

是否可以以某种方式使用 OR 运算符?有哪些选择?

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

推荐答案

我认为它应该适用于联合类型:http://www.w3.org/TR/xmlschema-0/#UnionDt

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

这篇关于是否可以编写 XML 模式以允许 xs:date 或 xs:dateTime 的 xs:attribute?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆