加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 断言无效,错位或过于频繁发生

发布时间:2020-12-16 23:27:59 所属栏目:百科 来源:网络整理
导读:在尝试生成我的XSD时,我正在遇到这个错误,无法弄清楚我做错了什么;我的代码看起来像这样: ?xml version="1.0" encoding="UTF-8"?xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://www.w3schools.com"xmlns="http://www.w3sch
在尝试生成我的XSD时,我正在遇到这个错误,无法弄清楚我做错了什么;我的代码看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="FICH">
<xs:complexType>

<xs:sequence>
<xs:element name="cabeza">
<xs:complexType>
<xs:sequence>
<xs:element name="VERSION_ORIG" type="Version"/>

</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="DATA_MAJ">
<xs:complexType>
<xs:sequence>
<xs:element name="DATA1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>

<xs:element name="VERSION_SIT_NOM" type="Version"/>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>

<xs:assert test="CABEZA/VERSION_ORIG = DATA_MAJ/VERSION_SIT_NOM"/>

</xs:complexType>
</xs:element>
<xs:simpleType name="YYMM">
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9]{2}[01|02|03|04|05|06|07|08|09|10|11|12]"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Version">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{2}.[0-9]{2}.[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="emptyString">
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

我们的想法是元素CABEZA / VERSION_ORIG必须等于DATA_MAJ / VERSION_SIT_NOM.我正在寻找一些解决方案,但一切似乎都适合我.

提前致谢

解决方法

您的架构文档对我来说看起来不错(更重要的是,对Saxon 9也是如此).

因此,错误消息的最可能原因是(1)您使用的是XSD 1.0处理器来处理XSD 1.1架构文档,以及(2)在这种情况下,您的处理器不提供世界上最好的错误消息.此时(2013年初)XSD 1.1由Saxon和Xerces J的测试版支持.如果您正在使用其他XSD验证器,您可能需要联系供应商或开发人员询问他们何时支持XSD 1.1. (如果他们认为用户不关心,没有人会转向1.1.)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读