次の方法で共有


<xsd:simpleContent> 要素

コンテンツとして文字データまたは simpleType 要素を含む complexType 要素に対する拡張または制限を保持し、要素は保持しません。

<simpleContent
  id = ID 
  {any attributes with non-schema Namespace}...>
Content: (annotation?, (restriction | extension))
</simpleContent>

属性

  • id
    この要素の ID。id の値は ID 型である必要があり、この要素を含んでいるドキュメント内で一意である必要があります。

    省略可能です。

要素情報

出現回数

1 回

親要素

complexType

コンテンツ

オプション : annotation

必須 : restriction (simpleContent) または extension (simpleContent) のどちらか 1 つのみを指定します。

解説

simpleContent 要素を使用すると、要素を持たない simpleType のコンテナ要素を指定でき、属性を設定してその要素のコンテンツの値を制限したり、要素を拡張したりできます。たとえば、次の要素宣言では、属性 (sizing など) を追加できません。

<xs:element name="shoeSize" type="xs:decimal"/>

simpleContent 要素を使用して、要素のコンテンツを単一の属性 (sizing) を持つ decimal 型として定義する complexType 要素を含める要素宣言の例を次に示します。

<xs:element name="shoeSize">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:decimal">
        <xs:attribute name="sizing">
         <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="US"/>
            <xs:enumeration value="European"/>
            <xs:enumeration value="UK"/>
            <xs:enumeration value="Japan"/>
          </xs:restriction>
         </xs:simpleType>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>

コメント

単純なコンテンツは、次のいずれかの方法で定義する必要があります。

restriction 要素

要素の値の範囲を、継承した simpleType の値の範囲のサブセットに制限します。

extension 要素

属性を追加して、要素のコンテンツ simpleType を拡張します。

匿名の complexType (名前のない complexType) を使用して、そのコンテンツを decimal データ型として定義し、currency 属性を設定した要素 (generalPrice) を宣言する例を次に示します。

<xs:element name="generalPrice">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:decimal">
        <xs:attribute name="currency" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>

その他のリソース

詳細については、www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all で公開されている、W3C 勧告『XML Schema Part 1: Structures』を参照してください。

参照

リファレンス

XML スキーマ (XSD) リファレンス
XML スキーマの要素