XML Schema simpleContent 元素

定義和用法

simpleContent 元素包含對 complexType 元素(它以字符數據或 simpleType 元素為內容)的擴展或限制并且不包含任何元素。

元素信息

出現次數 一次
父元素 complexType
內容

可選項 — annotation

必選項 — 有并且只有一個下列元素: restriction (simpleContent) 或 extension (simpleContent)。

語法

<simpleContent
id=ID
any attributes
>
(annotation?,(restriction|extension))
</simpleContent>

(? 符號聲明在 simpleContent 元素中該元素可出現零次或一次。)

屬性 描述
id 可選。規定該元素的唯一的 ID。
any attributes 可選。規定帶有 non-schema 命名空間的任何其他屬性。

實例

例子 1

這是一個僅包含文本的 XML 元素 (<shoesize>):

<shoesize country="france">35</shoesize>

下面的例子聲明了一個復雜類型 "shoesize",其內容被定義為整數數據類型,并帶有一個 country 屬性:

<xs:element name="shoesize">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:integer">
        <xs:attribute name="country" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>