XML Schema defines the elements of the XML file.
Simple elements are those that contain only text. It does not contain any other elements or attributes. Simple elements are those that contain only text. It does not contain any other elements or attributes. However, the limitation of “text only” can easily be misunderstood. There are many types of text. It can be one of the types included in the XML Schema definition (Boolean, string, data, etc.), or it can be a custom type that you define yourself. You can also limit its content by adding qualifications (that is, facets) to the data type, or you can require the data to match a particular schema. Define the syntax for 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. Xs:string Xs:decimal Xs:integer Xs:boolean Xs:date Xs:time Here are some XML elements: This is the corresponding simple element definition: Simple elements can have specified default values or fixed values. When no other value is specified, the default value is automatically assigned to the element. In the following example, the default value is “red”: A fixed value is also automatically assigned to the element, and you cannot specify another value. In the following example, the fixed value is “red”:What are simple elements? ¶
Define simple elements ¶
<xs:element name="xxx" type="yyy"/>
The most common types are: ¶
Example ¶
<lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>
Default values and fixed values for simple elements ¶
<xs:element name="color" type="xs:string" default="red"/>
<xs:element name="color" type="xs:string" fixed="red"/>