我正在使用eclipse来编辑和XML模式文件。我有两个文件,一个文件和两个文件。
文件一似乎没问题,但因为文件二引用文件二(外键),我有这个错误。虽然从代码中可以看出文件一个有namespace
。我需要一些帮助。
src-resolve.4.1: Error resolving component 'pk_Top_200_Queries2'.
It was detected that 'pk_Top_200_Queries2' has no namespace,
but components with no target namespace are not referenceable
from schema document
'file:///C:/java/workspace2/HomeWork2/Clicked_and_pos_12.xsd'.
If 'pk_Top_200_Queries2' is intended to have a namespace, perhaps
a prefix needs to be provided. If it is
intended that 'pk_Top_200_Queries2' has no namespace, then
an 'import' without a "namespace" attribute should be added to
'file:///C:/java/workspace2/HomeWork2/Clicked_and_pos_12.xsd'.
文件1:name = Top_200_Queries2,架构在
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Top_200_Queries2"
xmlns="http://www.example.org/Top_200_Queries2"
elementFormDefault="qualified">
<xsd:element name="T200Q">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="t200q" maxOccurs="200">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="qid" type="xsd:string" />
<xsd:element name="query" type="xsd:string" />
<xsd:element name="count" type="xsd:integer" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="pk_qid">
<xsd:selector xpath=".//t200q" />
<xsd:field xpath="qid" />
</xsd:key>
</xsd:element>
</xsd:schema>
fiel 2 name = Clicked2.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Clicked2"
xmlns="http://www.example.org/Clicked2" elementFormDefault="qualified">
<xsd:element name = "Clicked2">
<xsd:complexType>
<xsd:sequence>
<xsd:element name = "clicks" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="qid" type="xsd:string"/>
<xsd:element name="uid" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="pk_Clicked2">
<xsd:selector xpath=".//clicks"/>
<xsd:field xpath="qid"/>
<xsd:field xpath="uid"/>
</xsd:key>
<xsd:keyref name="fk_contains_query" refer="pk_Top_200_Queries2">
<xsd:selector xpath=".//clicks"/>
<xsd:field xpath="qid"/>
</xsd:keyref>
<xsd:keyref name="fk_contains_url" refer="pk_URL">
<xsd:selector xpath=".//clicks"/>
<xsd:field xpath="uid"/>
</xsd:keyref>
</xsd:element>
</xsd:schema>
两个文件都在eclipse中的同一个包中。
答案 0 :(得分:0)
您提供两个文件,其名称为Top_200_Queries2
和Clicked2.xsd
。乍一看,它们看起来还不错。
您引用的错误消息未提及这些文件名,而是提及名为pk_Top_200_Queries2
和Clicked_and_pos_12.xsd
的文件。因此,首先要问的问题是:处理器实际上是在读取您希望它读取的文件,还是在读取其他一些架构文档?