我有一个XSD文件,想要使用xs:assert
语句。问题是我不知道如何使断言功能对我可用。我正在使用Visual Studio进行编写,但它会出现蓝线提示不支持assert元素。
我的XSD文件看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.client.co.uk/quote"
targetNamespace="http://www.client.co.uk/quote"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="ProductType" type="ProductCodeType"/>
<xs:simpleType name="ProductCodeType">
<xs:annotation>
<xs:documentation>Client Product Type</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="L" />
<xs:enumeration value="C" />
<xs:enumeration value="H" />
</xs:restriction>
</xs:simpleType>
<xs:element name="BenefitBasisType">
<xs:simpleType>
<xs:annotation>
<xs:documentation>Client benefit basis type</xs:documentation>
</xs:annotation>
<xs:assert test= "if (ProductType = 'L') then $value = 'M' else if (ProductType = 'C') then $value = 'F' else if (ProductType = 'H') $value = 'P'" />
<xs:restriction base="xs:string">
<xs:enumeration value="M" />
<xs:enumeration value="F" />
<xs:enumeration value="P" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>