2016-09-21 4 views
1

XML Schemaアプリケーションに問題があります。最初のケースでは、要素を参照するシーケンスが1つありました。この場合は動作しますが、1つの要素onlyonemainの要素、またはonlyoneの要素がproblemの要素(mainの要素ではありません)を許可する要求があります。私は多くの解決策を特にシーケンスに分割し、要素をproblemという新しい定義要素として参照しようとしました。これは動作しますが、problemcomplexTypeを追加すると、エラーとして警告されます。私はそこに新しい要素problemが要求される条件が必要です。XSD検証エラー:cos-element-consistent:要素が要素と一貫性がありません

XSD:

<xs:sequence> 
    <xs:sequence> 
    <xs:element ref="el1" minOccurs="1" maxOccurs="1"/> 
    <xs:choice minOccurs="0" maxOccurs="unbounded"> 
     <xs:element ref="el2" minOccurs="0" maxOccurs="1"/> 
     <xs:element name="problem" minOccurs="0" maxOccurs="unbounded"> 
     <xs:complexType> 
      <xs:choice> 
      <xs:sequence> 
       <xs:choice minOccurs="0" maxOccurs="unbounded"> 
       <xs:element ref="inside1" maxOccurs="unbounded"/> 
       <xs:element ref="inside2" maxOccurs="unbounded"/> 
       </xs:choice> 
      </xs:sequence> 
      </xs:choice> 
     </xs:complexType> 
     </xs:element> 
     <xs:element ref="onlyone" minOccurs="0" maxOccurs="1"/> 
    </xs:choice> 
    <xs:element ref="el3" minOccurs="1" maxOccurs="1"/> 
    </xs:sequence> 
    <xs:sequence> 
    <xs:element ref="el1" minOccurs="1" maxOccurs="1"/> 
    <xs:choice minOccurs="0" maxOccurs="unbounded"> 
     <xs:element ref="el2" minOccurs="0" maxOccurs="1"/> 
     <xs:element name="problem" minOccurs="0" maxOccurs="unbounded"> 
     <xs:complexType> 
      <xs:choice> 
      <xs:sequence> 
       <xs:choice minOccurs="0" maxOccurs="unbounded"> 
       <xs:element ref="inside1" maxOccurs="unbounded"/> 
       <xs:element ref="onlyone" minOccurs="0" maxOccurs="1"/> 
       <xs:element ref="inside2" maxOccurs="unbounded"/> 
       </xs:choice> 
      </xs:sequence> 
      </xs:choice> 
     </xs:complexType> 
     </xs:element> 
    </xs:choice> 
    <xs:element ref="el3" minOccurs="1" maxOccurs="1"/> 
    </xs:sequence> 
</xs:sequence> 

そして保存するときにXMLSpyには、私を書き込みます

Element 'problem' is not consistent with element 'problem' a cos-element-consistent.1: Both type definitions ('{anonymous}' and '{anonymous}') must be named.

答えて

0

XSDコンテンツ・モデル内の同じ名前の要素が一貫性のあるコンテンツモデルを持っていることが必要ですElement Declarations Consistent制約があります。 problem要素は、同じ上位コンテンツモデル内に2つの異なるコンテンツモデルを持つことによってこの制約に違反し、実際には問題になります。

分解能は以下のいずれかの形式をとることができます。

  1. problem要素の一つの名前を変更します。
  2. )がxs:element/@ref介して(良好、 一貫性(二problem要素のコンテンツモデルは、一般的に参照してください。
  3. は、2つの矛盾problemコンテンツモデル間の兄弟関係を削除。
関連する問題