2017-12-19 14 views
2

以下はXMLスキーマの後ろに検証する.xmlファイルです。XSDエラー:このスキーマから名前空間のないコンポーネントへの参照は許可されていません。

私はこの分野での初心者や、複雑なタイプとして「グローバル」タイプを、作成するために、名前空間をされて使用しての私の理解だ

Element '{ http://www.w3.org/2001/XMLSchema }element', attribute 'type': References from this schema to components in no namespace are not allowed, since not indicated by an import statement.

エラーを受信し続ける「OneType」私はグローバルに再利用。

ご協力いただきましてありがとうございます。

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:tns="test/namespace" targetNamespace="test/namespace" 
elementFormDefault="qualified"> 
<xsd:complexType name="OneType"> 
    <xsd:annotation> 
     <xsd:documentation>One Test</xsd:documentation> 
    </xsd:annotation> 
      <xsd:choice> 
       <xsd:element name="One"/> 
      </xsd:choice> 
</xsd:complexType> 


<xsd:element name="testroot"> 
    <xsd:complexType> 
     <xsd:sequence> 
      <xsd:element name="Test" type="OneType"/> 
     </xsd:sequence> 
    </xsd:complexType> 
</xsd:element> 

<?xml version="1.0" encoding="UTF-8"?> 
    <tns:testroot xmlns:tns="test/namespace"> 
    <tns:Test> 
     <tns:One/> 
    </tns:Test> 
    </tns:testroot> 

答えて

2

<xsd:element name="Test" type="tns:OneType"/> 

<xsd:element name="Test" type="OneType"/> 

を交換した後、あなたのXSDは、エラーを持っていないだろう、とあなたのXMLがあなたのXSDに対して有効となります。

関連する問題