我需要通過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定義。我不明白他問題的根源是什麼
感謝您的幫助。
回到您問題的第一個版本:請不要從您的帖子中刪除重要信息,非現場鏈接不夠穩定 - 您的帳戶似乎已經過期。 –