280 likes | 560 Views
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”.
E N D
Schema • A schema is a collection of: • type definitions • simple type • complex type (contains element or attribute) • element declarations
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 • normalizedString • token • byte • unsignedByte • base64Binary • hexBinary • integer • positiveInteger • negativeInteger • nonNegativeInteger • nonPositiveInteger • int • unsignedInt • long • unsignedLong • decimal • float • double • boolean • time • dateTime • duration • date • anyURI • language • ..........
New simple types • by deriving from existing simple types (restricting)
Content Structure • all • sequence • choice