我需要通过xsd定义交换格式。我创建了一个示例xml文件,因为我打算这样做,并且想要测试它是否符合我创建的本地xsd,因此我尝试通过IntelliJIDEA验证它并获得了以下错误。请指出我做错了什么。针对自制模式的XML验证
<?xml version="1.0" encoding="UTF-8"?>
<dictionaryResponse
xmlns="http://dictionaries.persistence.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dictionaries.persistence.com dictionaries.xsd">
<entry>
<dictionaryCode>2</dictionaryCode>
<id>1</id>
<code>C</code>
</entry>
<entry>
<dictionaryCode>2</dictionaryCode>
<id>2</id>
<code>V</code>
</entry>
<entry>
<dictionaryCode>2</dictionaryCode>
<id>3</id>
<code>R2</code>
</entry>
<entry>
<dictionaryCode>2</dictionaryCode>
<id>4</id>
<code>TM</code>
</entry>
<entry>
<dictionaryCode>2</dictionaryCode>
<id>5</id>
<code>SN</code>
</entry>
<entry>
<dictionaryCode>2</dictionaryCode>
<id>6</id>
<code>SA</code>
</entry>
</dictionaryResponse>
dictionaries.xsd
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://dictionaries.persistence.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="dictionaryRequest">
<xs:sequence>
<xs:element name="dictionaryCode" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="dictionaryResponse">
<xs:sequence>
<xs:element name="entry" type="entry" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="entry">
<xs:sequence>
<xs:element name="dictionaryCode" type="xs:string"/>
<xs:element name="id" type="xs:string"/>
<xs:element name="code" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
错误:
Error:(12, 74) src-resolve.4.1: Error resolving component 'entry'. It was detected that 'entry' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///opt/idea-IC-141.1532.4/dictionaries.xsd'. If 'entry' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'entry' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///opt/idea-IC-141.1532.4/dictionaries.xsd'.
Error:(5, 83) cvc-elt.1: Cannot find the declaration of element 'dictionaryResponse'.
条目中相同的XSD定义。我不明白他问题的根源是什么
感谢您的帮助。
回到您问题的第一个版本:请不要从您的帖子中删除重要信息,非现场链接不够稳定 - 您的帐户似乎已经过期。 –