可选择的 XSD 架构 [英] XSD schema with choice
本文介绍了可选择的 XSD 架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要验证以下数组中的 XML 请求数据:
I need to validate XML request data in below array:
<studyYear></studyYear>
<orgID></orgID>
<originID></originID>
<providerID></providerID>
<userOID></userOID>
问题 - 我必须得到 (orgID
) 或 (userOID
) 或 (originID
和 providerID
) 一起.'studyYear' 将永远存在.我怎么能意识到呢?如果需要更多信息,请写信.我引用了这个 link 来尝试使用 xs:choice
在 xs:all
中,但无法让它工作.
Problem - I have to get either (orgID
) or (userOID
) or (originID
and providerID
) together. 'studyYear' will always be there. How I can realise it? If need more information just write. I referenced this link to use so as to try using xs:choice
inside xs:all
but could not get it working.
推荐答案
这个 XSD,
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="r">
<xs:complexType>
<xs:sequence>
<xs:element name="studyYear" type="xs:string"/>
<xs:choice>
<xs:element name="orgID" type="xs:string"/>
<xs:element name="userOID" type="xs:string"/>
<xs:sequence>
<xs:element name="orginID" type="xs:string"/>
<xs:element name="providerId" type="xs:string"/>
</xs:sequence>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
将要求 studyYear
后跟以下情况之一,
will require studyYear
to be followed by one of the following cases,
orgID
,或userOID
,或originID
和providerID
orgID
, oruserOID
, or- both
originID
andproviderID
根据要求.
这篇关于可选择的 XSD 架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文