XML SCHEMA Schema l A schema is a

  • Slides: 18
Download presentation
XML SCHEMA

XML SCHEMA

Schema l A schema is a collection of: l type definitions l simple type

Schema l A schema is a collection of: l type definitions l simple type l complex type (contains element or attribute) l element declarations

Example xml & xsd

Example xml & xsd

Complex Type Definitions • The elements must appear in the same sequence • The

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 •

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 l For elements: l l l For attributes the “use” attribute has

Occurrence Constraints l For elements: l l l For attributes the “use” attribute has the following value: l l l min. Occurs: default 1 max. Occurs: defalut 1 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

Global Elements The declaration enables the element to appear at the top-level of an instance document l In the example, both purchase. Order and comment can be the root l cardinality constraints can not be put to global declarations l

Simple Types l l l l string normalized. String token byte unsigned. Byte base

Simple Types l l l l string normalized. String token byte unsigned. Byte base 64 Binary hex. Binary integer positive. Integer negative. Integer non. Negative. Integer non. Positive. Integer int unsigned. Int long l l l unsigned. Long decimal float double boolean time date. Time duration date any. URI language. .

New simple types l by deriving from existing simple types (restricting)

New simple types l by deriving from existing simple types (restricting)

Enumeration

Enumeration

List Types

List Types

Union Type

Union Type

Anonymous Type

Anonymous Type

Complex Types from Simple Types

Complex Types from Simple Types

Empty Content

Empty Content

Content Structure all l sequence l choice l

Content Structure all l sequence l choice l

Choice & Group

Choice & Group

All

All