- Advantages of XML Schema
- Support for data-types
- Uses XML syntax
- Support for content model ( mixed content, exact number of occurences of elements, named group of elements)
- Self documenting
- Schema components is a generic term for the blocks that make up the abstract data model of the schema
- 3 groups of components : Primary, Secondary, Helper
- Primary components:
- Element declaration
- Simple type definition:
Built-in types: Primitive, Derived
3 varieties of data-types: Atomic, List, Union
User derived types
- Complex type definition
- Attribute Declaration
- Default value of minOccurs and maxOccurs is 1
- Element declaration can be local or global. Global – child of the “schema” element. Local – nested inside schema structure and not direct child of schema element
- MinOccurs and maxOccurs cant be used with global element declaration
- Any globally defined element can be used as the root element of a document
- Attribute values are always simple types
- Attributes are unordered.
- Attributes can be global or local
- “use” attribute cannot be used in globally declared attributes
- It does not matter whether complex type is defined before or after the element declaration as long as it is present in the schema document
- Simple type can not have any child elements or carry attributes.
- Simple types are the atoms of information considered distinct to XML Schema and they cannot be split up.
- Primitive data types are data types in their own right and they are not defined in terms of other types
- Derived typed are built from the definitions of other data-types
- User derived types are derived by the author of the schema and are particular to that schema.
- Atomic data type is one that has a value that cannot be divided atleast not in the context of XML Schema. Atomic data type is not analogous to primitive type. Atomic type can be primitive or derived.
- Built-in list types are: IDREFS, ENTITIES, NMTOKENS
- Named complex type is created when the content model is to be reused, otherwise anonymous types can be created.
- “schema” is the root element of the Schema document.
- Attributes are to be defined as part of the complex type because simple types can only hold atomic values and not carry attributes or have child elements.
- Content models – ANY, EMPTY, Element only, Mixed
- ANY is the default content model
- EMPTY- for this, define a complex type and restrict it from anyType so that it can only carry attributes.
- Secondary components:
- Model group definition
- Attribute groups
- Notation declaration
- Identity constraints
Key and KeyRef
Default or Fixed element content
Specifying null values
- Notation declaration – associates a name with an identifier for an application used to view that sort of a notation.
- Key and KeyRef – primary and foreign key respectively.
- XML Schema data types are composed of three parts: Value space, Lexical space, Set of facets.
- Value spaces have certain facets: order, bound, cardinality, equality, numeric or non-numeric dichotomy.
- Default data-type for any element is “string”
- “all”, “sequence” and “choice” are three compositors
- all – all the elements can occur in any order. Elements can occur only once or not at all
- choice – any one of the elements can occur, but only one
- sequence – elements occur in the specified order
- minOccurs and maxOccurs can’t be set to more than 1 in “all” compositor
- sequence and choice compositors can be combined whereas “all” cannot be combined with any other compositor
1. Ask your questions or clarify your/others doubts from,