1

我正在使用 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:名称 =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>

字段 2 名称 = 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中的同一个包中。

4

1 回答 1

0

你提供了两个文件,你说它们的名字是Top_200_Queries2Clicked2.xsd。乍一看,它们看起来不错。

您引用的错误消息没有提到这些文件名中的任何一个,而是提到了名为pk_Top_200_Queries2and的文件Clicked_and_pos_12.xsd。所以要问的第一个问题是:处理器实际上是在读取您希望它读取的文件,还是在读取其他一些模式文档?

于 2013-01-23T08:26:37.430 回答