xml - xml disorder elements with occurs more than 1
问题描述
I want to change complexType in xsd so that it support disorder elements and multiplely occuers elements.
Let's say, I have xsd and config1 as below, and I also want to support both config1 and config2 without changing config1. (config 1 and 2 differs in some element order(IsEnable and Name).) Is that possible?
I try to replace xs:sequence with xs:all, but elements under xs:all can only occuer exact 0 or 1 time.
//xsd
<xs:element name="Config">
<xs:complexType>
<xs:sequence>
<xs:element name="IsEnabled" type="xs:boolean" minOccurs="1" />
<xs:element name="Name" type="xs:string" minOccurs="1" />
<xs:element name="Address" type="xs:string" minOccurs="0" maxOccurs="unbounded">
</xs:sequence>
</xs:complexType>
</xs:element>
//config1
<Congfig>
<IsEnable>true</IsEnable>
<Name>name</Name>
<Address>addr1</Address>
<Address>addr2</Address>
</Config>
//config2
<Congfig>
<Name>name</Name>
<IsEnable>true</IsEnable>
<Address>addr1</Address>
<Address>addr2</Address>
</Config>
解决方案
XSD 1.0 不允许您这样做。
您可以在 XSD 1.1 中执行此操作。
推荐阅读
- php - Laravel:如何创建一个新行并将其附加到我的模型
- php - PHP:加入两个数组
- bdd - 引诱报告中的场景
- javascript - 如何使用 jquery 设置重置选项
- sql-server - 如果变量具有任何值,则 SQL Server 中 where 子句中的 case 语句,否则比较当前
- android - Kotlin 中的 STRING_TOO_LARGE 字符串
- swift - 致命错误:意外发现 nil - 创建 UIImage 时
- r - 使用 R 中的列表计算 MACD
- angular - FormIO + Angular - 回复更改输入
- c# - Rebus & RabbitMq 似乎总是使用“RabbitTopics”交换