Easy Tutorial
❮ El Complexcontent Schema Dtypes Numeric ❯

XSDSimple Elements


XML Schema defines elements in an XML file.

Simple elements are those that contain only text. They do not contain any other elements or attributes.


What is a Simple Element?

A simple element is one that contains only text. It does not contain any other elements or attributes.

However, the term "contains only text" can be misleading. Text can be of various types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc.), or it can be a custom type you define.

You can also add constraints (facets) to the data type to restrict its content, or you can require the data to match a specific pattern.


Defining Simple Elements

The syntax for defining a simple element:

Here, xxx refers to the element's name, and yyy refers to the element's data type. XML Schema has many built-in data types.

The most common types are:

Example

Here are some XML elements:

Here are the corresponding simple element definitions:


Default and Fixed Values for Simple Elements

Simple elements can have specified default or fixed values.

The default value is automatically assigned to the element when no other value is specified.

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":

❮ El Complexcontent Schema Dtypes Numeric ❯