XML schema is the basis for the description of data types, regardless of the selected classification. The following sections describe some of the basic concepts.
XML schema has the following data type categories:
Category | Meaning | Examples |
Built-In Type | Built-in data types are part of the XML schema language and have the prefix xsd. (They can also be subdivided into primitive and derived data types, but this is not important in the definition of data types). XML schema defines a value range for each built-in data type. | xsd:string xsd:decimal xsd:integer |
Simple Type | Simple data types refine built-in data types, for example, by limiting the length of a string or by specifying a specific value range. Like built-in data types, they do not contain any further elements. | <simpleType name=germanPhoneNumber base=string> <pattern value=?\d{4}?/?\d{6} /> </simpleType> |
Complex Type | Data types that can contain further elements and attributes. Elements and attributes can in turn reference built-in, simple, complex, or global data types. This enables large complex data types to be structured using smaller complex data types. | <complexType name=person> <element name=firstname type=string /> <element name=lastname type=string /> </complexType> |
Complex Type with SimpleContent | Complex types with simpleContent are data types with a root element that has a textual XSD type (for example, xsd:string), but that otherwise only have attributes and subelements. |
To describe complex data types in XML schema, use elements and attributes:
Node Type | Use | Example Instance |
Element | Create structured data types. Elements that have a type cannot contain subelements. | <myElem> <f1> Value of f1</f1> <f2> Value of f2</f2> </myElem> |
Attribute | Add attributes to elements. Attributes cannot usually have subnodes. | <myElem myAttr="AttributeValue"># Element Value#</myElem> |
The difference between elements and attributes is that attributes cannot have any subnodes, and that the same attribute cannot be used more than once in an element.
XML schema does not recognize tables but permits instead the definition of elements that can occur frequently in a schema (maxOccurs=unbounded
). Depending on the target language, proxy generation generates either a table type with a structure for the line type (ABAP), or class for accessing using a list (Java).
Facets enable you to restrict the value range of a data type in XML schema to a particular subset. This enables you to determine exactly which value is expected in a special case for a simple data type, an element, or an attribute. For example:
A telephone number (using a pattern on a string)
A selection of permitted values, for example to classify the different classes for a flight (using an enumeration)
More information: XSD Editor for Freely-Modeled Data Types
You can structure data types in a nested way by referencing data types from a complex data type. However, you must ensure that the referencing and the referenced data type are shipped together otherwise the data type definition is not complete. For this reason, the following restrictions exist for the use of data types (more information: Object References):
Category | Can Be Referenced In |
---|---|
Built-In Type | All software component versions |
Simple Type | The same software component version or a sub-software component version of the referencing freestyle data type. |
Complex Type | The same software component version or a sub-software component versions of the referencing freestyle data type. |
Core Data Type | The same software component version or a sub-software component version of the referencing aggregated data type |
Aggregated Data Type | The same software component version or a sub-software component version of the referencing aggregated data type |
Caution
You cannot structure data types recursively, that is, references of type
and transitive references of type are not permitted.