2016-11-26 2 views
1

私はsimpleType要素内にオプションの要素を配置しようとしていますので、complexTypeに変更しました。今私はcomplexType内部にcomplexTypeを持っていて、バリデーターはそれが間違っていると言います、どうすれば修正できますか?ComplexType内のComplexType

<glowne_role> 
    <aktor>William H. Macy</aktor> 
    <aktor> 
     Frances McDormand 
     <komentarz>Prywatnie aktorka jest żoną reżysera.</komentarz> 
    </aktor> 
    </glowne_role> 


<xs:element name="komentarz" type="xs:string" /> 

<xs:complexType name="glowne_role"> 
    <xs:complexType name="aktor" minOccurs="1" maxOccurs="3" type="xs:string"> 
    <xs:element ref="komentarz" minOccurs="0"/> 
    </xs:complexType> 
</xs:complexType> 

答えて

1

あなたは直接ではなく、xs:complexType内部xs:complexTypeを持つことができます。あなたのXMLに基づいて、glowne_roleという要素を、aktor要素のシーケンスで構成される複合型に定義したいとします。それぞれの要素はで、は複合型でもかまいません。テキストをkomentarzの前に置くことができるようにするには、を親のxs:complexTypeに設定することができます。

要するに、その後、このXSDは正常にXMLを検証します:あなたの答えのための

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="komentarz" type="xs:string"/> 
    <xs:element name="glowne_role"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="aktor" minOccurs="1" maxOccurs="3"> 
      <xs:complexType mixed="true"> 
      <xs:sequence> 
       <xs:element ref="komentarz" minOccurs="0"/> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 
+0

感謝を! –

関連する問題