Javascript
XML Schema
XML SCHEMAS
similar to DTD
schemas are used
to define the
structure of the
document
DTDs disadvantages:
DTDs disadvantages:
Difficult to deal
with 2 different
types of syntaxes
DTDs disadvantages:
Schema Fundamentals
Schemas can be
considered as a class in
object oriented
programming
XML document as
Instance of Schemas
1.
Specifies elements
and attribute of
XML Document
3.
Defining A Schema
Defining A Schema
schema of schemas.
The name of this
namespace is
http://www.w3.org/2001/XMLSche
ma
Defining A Schema
xmlns:xsd =
http://www.w3.org/2001/XMLSche
ma
Defining A Schema
targetNamespace =
http://cs.uccs.edu/planeSchema
Defining A Schema
schema of schemas.
The name of this
namespace is
http://www.w3.org/2001/XMLSche
ma
Defining A Schema
elementFormDefault
= qualified
Defining A Schema
The default
namespace,
xmlns =
http://cs.uccs.edu/planeSc
hema
Defining A Schema
Instance
Defining A Schema
Instance
default
namespace
<planes
xmlns=http://cs.uccs.edu/planeSchema
...
>
xsi:schemaLocation
=
http://cs.uccs.edu/p
laneSchema/planes.x
sd
Combining everything,
we get
2 User-defined
schema data types:
Simple
Complex.
<xs:element
name="xxx"
type="yyy"/>
Example
<lastname>Raj</lastna
me>
<xs:element
name="lastname"
type="xs:string"/>
Example
<age>36</age>
<xs:element
name="age"
type="xs:integer"/>
Example
<dateborn>1970-03-27
</dateborn>
<xs:element
name="dateborn"
type="xs:date"/>
xs:string,
xs:decimal,
xs:integer,
xs:boolean,
xs:date,
xs:time
byte,
long,
decimal,
unsignedInt,
positiveInteger,
NMTOKEN
defined by specifying
restrictions on an
existing type, which is
then called a base
type.
Password element is a
string type, between
six and 12 characters
<xs:simpleType
name="passwordType">
<xs:restriction
base="xs:string">
<xs:minLength value=6>
<xs:maxLength value=12>
</xs:resrtiction>
</xs:simpleType>
restrictions on an existing
type
Employee Number
element is a integer
data type, greater than
or equal to 1,000 and
less than 10,000
<xs:simpleType name="snoType">
<xs:restriction base="xs:int">
<xs:minInclusive value="1000"/>
<xs:maxExclusive value="10000"/>
</xs:restriction>
</xs:simpleType>
The snoType Employee_Number element
declaration is as follows:
<xs:element name="Employee_Number"
type="snoType" />
restrictions on an existing
type
Department element is
a string type, limited to
either "Sales,"
"Development" or
"Service Department
<xs:simpleType name="belongType">
<xs:restriction base="xs:string">
<xs:enumeration value="Sales"/>
<xs:enumeration
value="Development"/>
<xs:enumeration value="Service"/>
</xs:restriction>
</xs:simpleType>
The belongType type Department element
declaration is as follows:
<xs:element name="Department"
type="belongType" />
<xs:element name="color"
type="xs:string"
default="red"/>
<xs:element name="color"
type="xs:string"
fixed="red"/>
default attribute:
Fixed attribute
Sequence
All
Ordered Element
Unordered
Choice
Complex Types
minOccurs attributes
maxOccurs attributes
DTD
<!ELEMENT e1 ((e2,e3?)
+|e4)>
Schema
<xs:element name=e1>
<xs:complexType>
<xs:choice>
<xs:sequence maxOccurs=unbounded>
<xs:element name=e2 type=xs:string/>
<xs:element name=e3 type=xs:string
minOccurs=0/>
</xs:sequence>
<xs:element name=e4 type=xs:string >
</xs:choice>
</xs:complexType>
</xs:element>
Displaying XML
Documents
Displaying XML
Documents
<?xml-stylesheet type
= "text/css" href =
file.css"?>
XSLT- EXtensible
Stylesheet Language
Transformations
Overview of XSLT
Functional-style
programming
language
The syntactic structure
of XSLT is XML,
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.
w3.org/1999/XSL/Transf
orm">