XML SCHEMA
Schema
A schema is a collection of:
– type definitions
simple type
complex type (contains element or attribute)
– element declarations
Example xml & xsd
Complex Type Definitions
• The elements must appear in the same sequence
• The attribute must contain “US”
Complex Type Definition
• The “ref” attribute is for referencing an existing element
• The value of this attribute must reference a global element (declared
directly under schema)
Occurrence Constraints
For elements:
– minOccurs: default 1
– maxOccurs: defalut 1
For attributes the “use” attribute has the following value:
– required
– optional (default)
– prohibited
“default” attribute is for both attribute and element definitions
default attribute values apply when attributes are missing,
default element values apply when elements are empty
Global Elements
The declaration enables the element to
appear at the top-level of an instance
document
In the example, both purchaseOrder and
comment can be the root
cardinality constraints can not be put to
global declarations
Simple Types
string unsignedLong
normalizedString decimal
token float
byte double
unsignedByte boolean
base64Binary time
hexBinary dateTime
integer duration
positiveInteger date
negativeInteger anyURI
nonNegativeInteger language
nonPositiveInteger ..........
int
unsignedInt
long
New simple types
by deriving from
existing simple types
(restricting)
Enumeration
List Types
Union Type
Anonymous Type
Complex Types from Simple Types
Empty Content
Content Structure
all
sequence
choice
Choice & Group
All