7/31/2019 Trains Chema
1/17
W3C XML SCHEMA TRAINING
7/31/2019 Trains Chema
2/17
Introduction to XML (1hr 30 Min)
Basic XML Rules
Databases (Relational and XML)
Data Storage and Retrieval
Why XML is choice over RDBMS
Why Schema (1 Hr)
Grammar for XML.
Why Grammar is needed? Well-formed vs Valid XML.
Introduction to DTD.
Why Schema, when DTD is there?
Validation of XML Using DTD and Schema
XML Editors (Oxygen, Altova XML Spy, Xmetal, Stylus Studio, XML Editor)
XML Parsers (SAX, MSXML, Xalan,LibXML, Xerces)
7/31/2019 Trains Chema
3/17
Formal Introduction
Schema is a language recommended by W3C in 2001
Schema is an XML document
Schema defines structure of XML instance document
Element NameAttribute Name
Order of Elements
Number of Element
Nesting of Element
Data type of Element and Attribute
Restrictions
Default Values
Schema Vs DTD
Data Types
Namespace
Inline DTD
XML Syntax
7/31/2019 Trains Chema
4/17
XML DTD SCHEMA
A7MarchDelhi7000
7/31/2019 Trains Chema
5/17
Referencing DTD Referencing Schema
A7MarchDelhi
7000
A7March
Delhi7000
Thisattributehastwo
values,separatedbya
space.Thefirstvalue
isthenamespaceto
use.Thesecondvalue
isthelocationofthe
XMLschematouse.
7/31/2019 Trains Chema
6/17
Starting Writing Schema
is the root element of every schema.
7/31/2019 Trains Chema
7/17
Simple Element
A simple element is an XML element that contains only text. It cannot contain any other elements or
attributes..
Syntax
name is any name given to the element, type could be any built-in data type or any custom data-type.
A simple element can have a default or fixed value.
7/31/2019 Trains Chema
8/17
Attributes
Attributes are declared and simple types.
Syntax
name is any name given to the attribute, type could be any built-in data type or any custom data-type.
7/31/2019 Trains Chema
9/17
Complex Element
A complex element is an XML element that contains child elements/attributes. An empty element is also
a complex element.
A complex element can have any of the following structure
empty element (with or without attribute)
element with child element (with or without attribute) but no content
element with child element (with or without attribute) and content as well (mixed content)
EXAMPLE
and
Neil
Scott
this employee joined on 7-3-2011 as
Analyst
7/31/2019 Trains Chema
10/17
7/31/2019 Trains Chema
11/17
Complex Element
Advantage of Modular MethodWe can reuse each type which serve as custom data type. Here personinfo act as custom data type andcan be reused as data type
Linear Method Modular Method
7/31/2019 Trains Chema
12/17
Built-in Types
7/31/2019 Trains Chema
13/17
Extending Complex Custom type
7/31/2019 Trains Chema
14/17
Restriction
Also called Facets, are used to define constraint on the values of elements or attributes.
Restriction Type Example
Values
Enumeration
7/31/2019 Trains Chema
15/17
Restriction
Restriction Type Example
7/31/2019 Trains Chema
16/17
IndicatorsOrder indicators: Occurrence indicators:
All maxOccurs
Choice minOccurs
Sequence
All specifies that the child elements can appear in any order,
and that each child element must occur only once
Choice specifies that either one child element or another canoccur
Sequence specifies that the child elements must appear in a
specific orde
maxOccurs
minOccurs
Specifies number of time an element can appear.
Default value is one, for unlimited use unbounded
7/31/2019 Trains Chema
17/17