XSD - 需要 2 个属性之一? [英] XSD - one of 2 attributes is required?

查看:10
本文介绍了XSD - 需要 2 个属性之一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法指定 XSD 中需要 2 个属性之一?

Is there a way to specify that one of 2 attributes is required in XSD?

例如,我有一个这样的定义:

for example, I have a definition like this:

<xs:attribute name="Name" type="xs:string" use="optional" />
<xs:attribute name="Id" type="xs:string" use="optional" />

我希望能够定义至少其中一项是必需的.这可能吗?

I want to be able to define that at least one of these is required. Is that possible?

推荐答案

不,我不认为你可以用属性来做到这一点.您可以将两个 <xs:element> 包装成一个 <xs:choice> - 但对于属性,恐怕没有等效的构造.

No, I don't think you can do that with attributes. You could wrap two <xs:element> into a <xs:choice> - but for attributes, there's no equivalent construct, I'm afraid.

这篇关于XSD - 需要 2 个属性之一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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