The best XML Schema Properties Tutorial In 2024, In this tutorial you can learn What is an attribute?,How to declare property?,The default value and the fixed value of the property,Optional and required attributes,Defining the content,
All attributes are declared as simple types.
Simple elements can not have attributes. If an element has attributes, it will be treated as some kind of complex type. But the property itself is always used as a simple type declaration.
The syntax is defined properties
Here, xxx is the property name, yyy provides that the data type of the attribute. XML Schema has a lot of built-in data types.
This is the XML elements with attributes:
This is the corresponding attribute definition:
Property has a specified default value or a 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 "EN":
Fixed values are also automatically assigned to the elements, and you can not predetermined additional value.
In the following example, the fixed value is "EN":
In case of default, the attribute is optional. To specify attributes is required, please use the "use" attribute:
When an XML element or attribute has a data type is defined, it will add to the content defining element or attribute.
If the type of XML element is "xs: date", and the content it contains is similar to "Hello World" string element will not (through) authentication.
Through XML schema, you can also add your own to define your XML elements and attributes. These limits are called facet (Editor's note: meaning (polyhedron) surface, can be translated as defined surface). You will learn more about the facet of knowledge in the following section.