如何解决尝试在XSD中添加type =“ xs:string”时出错
每当我尝试将目标类型添加为“ xs:字符串”时,都会出现此错误。我不确定是什么问题。如果删除XSD有效的类型,则需要它具有字符串类型,但是,当我添加它时,出现以下错误:
cvc-type.3.1.1:元素“目标”是一种简单类型,因此它不能具有属性,但那些命名空间名称与“ http://www.w3.org/2001/XMLSchema-instance”相同的属性除外”,其[本地名称]是“类型”,“ nil”,“ schemaLocation”或“ noNamespaceSchemaLocation”之一。但是,找到了“类型”属性。
<xs:complexType>
<xs:sequence>
<xs:element name="goal" type="xs:string" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
解决方法
根据Saxon模式处理器,您的模式正确,并且该实例有效。我一点都没发现任何问题。
您使用的是哪种架构处理器?
,合法XSD
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="interface">
<xs:complexType>
<xs:sequence>
<xs:element name="pack" type="xs:string" maxOccurs="1" />
<xs:element name="extension">
<xs:complexType>
<xs:sequence>
<xs:element name="from" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="import" maxOccurs="unbounded" minOccurs="0" type="xs:string" />
<xs:element name="method" maxOccurs="unbounded" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="level" type="xs:string" />
<xs:element name="arguments" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="goal" type="xs:string" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="throws">
<xs:complexType>
<xs:sequence>
<xs:element name="exception" maxOccurs="unbounded" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="return" type="xs:string" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
有效的XML示例
<?xml version="1.0" encoding="utf-8"?>
<interface xsi:noNamespaceSchemaLocation="Joseph.xsd" id="string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pack>string</pack>
<extension>
<from>string</from>
</extension>
<import>string</import>
<import>string</import>
<import>string</import>
<method name="string">
<level>string</level>
<arguments>
<goal>string</goal>
<goal>string</goal>
</arguments>
<throws>
<exception>string</exception>
<exception>string</exception>
<exception>string</exception>
<exception>string</exception>
<exception>string</exception>
</throws>
<return>string</return>
</method>
</interface>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。