XML Schema simpleContent Element

Definition and Usage

The simpleContent element extends or restricts a complexType element (which is content with character data or a simpleType element) and does not contain any elements.

Element Information

Occurrence Once
Parent Element complexType
Content

Optional - annotation

Mandatory - There must be exactly one of the following elements: restriction (simpleContent) or extension (simpleContent).

Syntax

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

The (? symbol indicates that the element can occur zero or one times within the simpleContent element.)

Attributes Description
id Optional. Ορίζει το μοναδικό ID του στοιχείου.
any attributes Οptional. Ορίζει οποιαδήποτε άλλη ιδιότητα με 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>