XSD Simple elements
XML Schema elements define XML file.
Simple elements are those elements contain only text. It does not contain any other elements or attributes.
What is a simple element?
Simple elements are those elements contain only text. It does not contain any other elements or attributes.
However, "it contains only text" restriction is very likely to cause misunderstanding. There are many types of text. It can be included in the definition of XML Schema type one (boolean, string, data, etc.), or it may be a custom type that you define yourself.
You can also add restrictions (ie, facets), in order to limit its content, or you can require the data to match a particular pattern to the data type.
Simple definition of the elements
Simple definition syntax elements:
Where xxx is the name of the element, yyy refers to the data type of the element. XML Schema has a lot of built-in data types.
The most common types are:
- xs: string
- xs: decimal
- xs: integer
- xs: boolean
- xs: date
- xs: time
Examples
Here are some XML elements:
<age>36</age>
<dateborn>1970-03-27</dateborn>
This is the corresponding simple element definitions:
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>
The default value of simple elements and a fixed value
Simple elements can have a specified default or fixed value.
When no other value is specified, the default value is automatically assigned to the element.
In the following example, the default value is "red":
Fixed values are also automatically assigned to the elements, and you can not predetermined additional value.
In the following example, the fixed value is "red":