XSD simple elements
XML Schema defines the elements of an XML file.
Simple elements refer to those elements that only contain text. It will not contain any other elements or attributes.
What are simple elements?
Simple elements refer to those elements that only contain text. It will not contain any other elements or attributes.
However, the "only text" limitation can easily lead to misunderstandings. There are many types of text. It can be one of the types included in the XML Schema definition (boolean, string, data, and so on), or it can be a custom type that you define yourself.
You can also add qualifications (i.e. facets) to a data type to limit its content, or you can require the data to match a specific pattern.
Define simple elements
The syntax for defining simple elements:
Here xxx refers to the name of the element, and yyy refers to the data type of the element. XML Schema has many built-in data types.
The most commonly used types are:
xs:string
xs:decimal
xs:integer
xs:boolean
- ##xs:date
- xs :time ##Example
Here are some XML elements:
<lastname>Refsnes</lastname>Default and fixed values of simple elements
Simple elements can have specified Default or fixed value.
The default value is automatically assigned to the element when no other value is specified.
In the following example, the default value is "red":
<xs:element name="color" type="xs:string" default="red "/>In the following example, the fixed value is "red":
<xs:element name="color" type="xs:string" fixed="red" />