1

Eclipse を使用して XML スキーマ ファイルを編集しています。ファイル 1 とファイル 2 の 2 つのファイルがあります。ファイル 1 は問題ないようですが、ファイル 2 がファイル 2 (外部キー) を参照しているため、このエラーが発生します。ファイル1のコードから見ることができますが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>

フィールド 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

と という名前の 2 つのドキュメントを提供しTop_200_Queries2ますClicked2.xsd。一見、問題ないように見えます。

あなたが引用したエラーメッセージは、これらのファイル名のいずれにも言及していませんが、代わりにpk_Top_200_Queries2および と呼ばれるファイルに言及していますClicked_and_pos_12.xsd。したがって、最初に尋ねる質問は、プロセッサが実際に読み取りたいファイルを読み取っているのか、それとも他のスキーマ ドキュメントを読み取っているのかということです。

于 2013-01-23T08:26:37.430 に答える