XSD assert not recognised

て烟熏妆下的殇ゞ 提交于 2019-12-10 19:36:16

问题


I have an XSD where I want to use an xs:assert statement. The issue is I don't know how to make the assert functionality available to me. I am using Visual Studio to write it, and it gets a blue line saying it doesn't support the assert element.

My XSD looks like this:

<?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>

回答1:


The problem is that xs:assert requires XSD 1.1, and Microsoft Visual Studio only supports XSD 1.0. You'll have to use an XML processor that supports XSD 1.1 such as one of the following:

  • Xerces-J with PsychoPath XPath 2.0
  • Saxon EE
  • Altova
  • Liquid XML also supports it


来源:https://stackoverflow.com/questions/32500445/xsd-assert-not-recognised

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!