XML Schema simpleContent Element
Definition and Usage
The simpleContent element contains an extension or restriction of the complexType element (which contains character data or a simpleType element as content) and does not contain any elements.
Element information
Occurrence | One |
Parent element | complexType |
Content |
Optional — annotation Mandatory option — One and only 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.)
Attribute | Description |
---|---|
id | Optional. Specify the unique ID of the element. |
any attributes | Optional. Specify any other attributes with a non-schema namespace. |
Instance
Example 1
This is an XML element containing only text (<shoesize>):
<shoesize country="france">35</shoesize>
The following example declares a complex type "shoesize", whose content is defined as an integer data type and includes a country attribute:
<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>