无需过多详细介绍,我们希望使用 XML 作为元数据来描述属性约束(这是一个缩减示例,XSD 不支持我们提出的复杂模型),有两个选项正在考虑,以下哪个 XML结构更有意义?
选项1)
<?xml version="1.0" encoding="us-ascii"?>
<Properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Property type="string">
<name>quanitity</name>
<contraints>
<contraint type="isRequired">
<value>true</value>
</contraint>
<contraint type="regex">
<value>^[0-9]$</value>
</contraint>
<contraint type="regex">
<value>^[a-zA-Z]$</value>
</contraint>
</contraints>
</Property>
</Properties>
选项 2)
<?xml version="1.0" encoding="us-ascii"?>
<Properties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Property type="string">
<name>quantity</name>
<IsRequired>true</IsRequired>
<Regex>^[0-9]$</Regex>
<Regex>^[a-zA-Z]$</Regex>
</Property>
</Properties>