Xsd-complex-empty

提供:Dev Guides
移動先:案内検索

XSD-複雑な空の要素

複合空要素は属性のみを持つことができ、コンテンツは持ちません。 次の例を参照してください-

<student rollno = "393"/>

私たちは、次のメソッドを使用して複雑な空の要素を宣言することができます-

タイプ属性を使用

複合型要素「StudentType」を定義してから、「StudentType」型の要素studentを作成します。

<xs:complexType name = "StudentType">
   <xs:attribute name = 'rollno' type = 'xs:positiveInteger'/>
</xs:complexType>

<xs:element name = 'student' type = 'StudentType'/>

ComplexContentを使用する

complexContentでcomplexTypeの要素を定義します。 ComplexContentは、要素のコンテンツを制限することを指定します。

<xs:element name = "student">
   <xs:complexType>
      <xs:complexContent>
         <xs:restriction base = "xs:integer">
            <xs:attribute name = "rollno" type = "xs:positiveInteger"/>
         </xs:restriction>
      </xs:complexContent>
   </xs:complexType>
</xs:element>

ComplexTypeのみを使用する

必須の属性要素のみでcomplexTypeの要素を定義します。

<xs:element name = "student">
   <xs:complexType>
      <xs:attribute name = "rollno" type = "xs:positiveInteger"/>
   </xs:complexType>
</xs:element>