无法识别 XSD 断言 [英] XSD assert not recognised

查看:26
本文介绍了无法识别 XSD 断言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 XSD,我想在其中使用 xs:assert 语句.问题是我不知道如何使断言功能对我可用.我正在使用 Visual Studio 编写它,它得到一条蓝线,表示它不支持 assert 元素.

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.

我的 XSD 如下所示:

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>

推荐答案

问题在于 xs:assert 需要 XSD 1.1,而 Microsoft Visual Studio 仅支持 XSD 1.0.您必须使用支持 XSD 1.1 的 XML 处理器,例如以下之一:

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:

这篇关于无法识别 XSD 断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆