如何基于属性值在XSD验证中动态枚举?

时间:2019-08-01 06:29:00

标签: xml visual-studio xsd-validation

我有一个示例xml节点,如下所示

<ExampleNode name="Example" productType="a" ><![CDATA[63]]></ExampleNode>

相应的XSD架构如下

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="ExampleNode" type="ExampleNodeType" />
    <xs:complexType name="ExampleNodeType">
        <xs:simpleContent>
            <xs:restriction base="CommonTypeFloat">
                <xs:enumeration value="1"/>
                <xs:enumeration value= "2" />
                <xs:enumeration value="3"/>
                <xs:enumeration value="4"/>
                <xs:enumeration value="5"/>
                <xs:enumeration value="6"/>
                <xs:enumeration value="7"/>
                <xs:enumeration value="8"/>
                <xs:enumeration value="9"/>
                <xs:enumeration value="10"/>
                <xs:enumeration value="11"/>
                <xs:enumeration value="63"/>
                <xs:enumeration value="81"/>
                <xs:enumeration value="90"/>
                <xs:enumeration value="92"/>
                <xs:enumeration value="93"/>
            </xs:restriction>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

示例节点是动态生成的,productType可以变化。 对于productType“ a”,我需要检查1-5的枚举 对于productType“ b”,我需要检查6-10的枚举 等等,

那么我们如何才能修改上述xsd限制,以根据productType属性值附加枚举?

我尝试使用xs:alternate,但是由于Visual Studio XSD验证不支持该标记而无法正常工作

我需要分别为productType“ a”,“ b”和“ c”分别具有枚举,并根据属性值附加它们。有可能

0 个答案:

没有答案
相关问题