Workshops --> XML --> Demo --> schema14.html
SLIS@IU logo

L595 XML@IU logo

Creating Schemas

Complex types

Useful attributes for complex types

With the minoccurs and maxoccurs attributes, the number of times a component can appear in an element can be set

These attributes can be used with

A single element
A sequence of elements
A choice of elements
An unordered group
A named group

The generic form is:

<xsd:element name="name" type="xsd:string" min/maxOccurs="x" />

Using minOccurs, it looks like this:

<xsd:element name="alien_probe" type="metallic" minOccurs="2" />

This element must appear at least twice in the XML file for the document to be valid

maxOccurs sets the maximum number of times an element can appearin a document for the document to be valid

Use of the attribute value "unbounded" means that the element can appear in the XML file any number of times

This is equivalent to the * in a DTD

If an element is defined globally (it appears below the opening xsd:schema element), it must be referenced in order to be used in the schema

The element can appear in different places and have different attributes

The global declaration looks like this:

<xsd:element name="somename" type="dataType" />

An example is

<xsd:element name="shape" type="xsd:string" />

This xsd:element can then be referenced anywhere in the schema

<xsd:element ref="shape" type="metallic" />

Each appearance of the element can have different attributes (particularly minOccurs and maxOccurs)

Home
schema schema 2 schema 3 schema 4 schema 5 schema 6 schema 7 schema 8 schema 9
Next

schema 10 schema 11 schema 12 schema 13 schema 14 schema 15 schema 16 schema 17

Page by Howard Rosenbaum
Find me at hrosenba@indiana.edu You are here: http://www.slis.indiana.edu/hrosenba/www/Workshops/XML/Demo/schema14.html