LibraryToggle FramesPrintFeedback

In XML Schema, data units that are a collection of data fields are defined using complexType elements. Specifying a complex type requires three pieces of information:

For example, the structure shown in Example 2.3 is be defined in XML Schema as a complex type with two elements.


Example 2.4 shows one possible XML Schema mapping for the structure shown in Example 2.3.


You define the data fields that make up a structure using element elements. Every complexType element should contain at least one element element. Each element element in the complexType element represents a field in the defined data structure.

To fully describe a field in a data structure, element elements have two required attributes:

In addition to name and type, element elements have two other commonly used optional attributes: minOcurrs and maxOccurs. These attributes place bounds on the number of times the field occurs in the structure. By default, each field occurs only once in a complex type. Using these attributes, you can change how many times a field must or can appear in a structure. For example, you can define a field, previousJobs, that must occur at least three times, and no more than seven times, as shown in Example 2.6.


You can also use the minOccurs to make the age field optional by setting the minOccurs to zero as shown in Example 2.7. In this case age can be omitted and the data will still be valid.


Comments powered by Disqus