You are on page 1of 56

XML

eXtensible Markup Language

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 1
Objective…

ƒTo understand the need and usage of XML in todays


applications
ƒTo gain an insight into the syntax and semantics of the
language
ƒTo understand the major differences and to familiarize with
DTD and XSD concepts
ƒTo understand the usage of XSL
ƒTo learn and write parsers for XML with a detailed study about
SAX and DOM parsers

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 2
Agenda… Day 1

(00:30) Introduction to XML


(00:30) Use of XML for E-Commerce
(00:15) Tea Break
(01:00) Namespaces
(01:00) Lunch break
(01:00) XML Schema
(01:00) XML Schema vocabulary
(00:15) Tea Break
(00:30) XPath
(01:00) Lab Exercise - Generation XML Schema.

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 3
Agenda… Day 2

(00:30) Introduction to XSL


(01:00) SAX Parser - introduction, Usage,
example Java Implementation

XML Assignments

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 4
XML
XML is a markup language for documents
containing structured information

Sample XML Document:

<?xml version="1.0"?>
<student id="101">
<name>kumar</name>
<age>21</age>
</student>
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 5
XML Declaration

<?xml version="version_number"
encoding="encoding_declaration"
standalone="standalone_status" ?>

Example:
<?xml version=“1.0” encoding=“UTF-8”
standalone=“yes” ?>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 6
XML Declaration Rules
„If the XML declaration is included, it must be
situated at the first position of the first line in the
XML document

„Ifthe XML declaration is included, it must contain


the version number attribute .

„Ifall of the attributes are declared in an XML


declaration, they must be placed in the order shown
above .

„The XML declaration must be in lower case (except


for the encoding declarations)

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 7
XML Declaration
Possible Attribute values:

Attributes Possible values


version 1.0
UTF-8, UTF-16, ISO-10646-
encoding UCS-2, ISO-10646-UCS-4,
ISO-8859-1 to ISO-8859-9,
ISO-2022-JP, Shift_JIS,
EUC-JP
standalone yes,no

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 8
XML Vs HTML
XML HTML
User definable tags Defined set of tags designed for
web display

Content driven Format driven

End tags required for well End tags not required


formed documents

Quotes required around Quotes not required


attributes values

Slash required in empty tags Slash not required

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 9
Namespace

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 10
Namespaces disambiguate elements
• Namespaces disambiguate elements with the
same name from each other by attaching
different prefixes to names from different
XML applications.

• Each prefix is associated with a URI.


– Names whose prefixes are associated with the
same URI are in the same namespace.
– Names whose prefixes are associated with
different URIs are in different namespaces.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 11
URIs
• Uniform Resource Identifier
• Two kinds:
– URLs: Uniform Resource Locators
– URNs: Uniform Resource Names
• Which should be used for namespaces?
• Absolute vs. relative

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 12
Namespace Syntax
• Elements and attributes that are in namespaces have
names that contain exactly one colon. They look like
this:
rdf:description
xlink:type
xsl:template
• Everything before the colon is called the prefix
• Everything after the colon is called the local part.
• The complete name including the colon is called the
qualified name.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 13
Namespace URIs
• Each prefix is associated with a URI (technically a URI
reference) called a namespace name.
• For example, all elements in XSLT 1.0 style sheets are
associated with the http://www.w3.org/1999/XSL/Transform
URI.
• The customary prefix xsl is a shorthand for the longer URI
http://www.w3.org/1999/XSL/Transform.
• You can't use the URI in the element name directly.
{http://www.w3.org/1999/XSL/Transform}template
http://www.w3.org/1999/XSL/Transform#templa
te

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 14
Binding Prefixes to Namespace URIs
• Prefixes are bound to namespace URIs by attaching an
xmlns:prefix attribute to the prefixed element or one of its
ancestors.
<svg:svg xmlns:svg="http://www.w3.org/2000/svg"
width="12cm" height="10cm">
<svg:ellipse rx="110" ry="130" />
<svg:rect x="4cm" y="1cm" width="3cm" height="6cm" />
</svg:svg>
• Bindings have scope within the element where they're
declared.
• An SVG processor recognizes all three of these elements as
SVG elements because they all have prefixes bound to the
particular URI defined by the SVG specification.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 15
Namespaces and Attributes
• An attribute can be placed in a namespace by
prefixing its name.
• Normally only used for global atributes that can
appear on any element such as XLink attributes
rather than attributes that are tied to a specific
element.
• Unprefixed attributes are never in any namespace.
• Being an attribute of an element in the
http://www.w3.org/1999/xhtml namespace is not
sufficient to put the attribute in the
http://www.w3.org/1999/xhtml namespace.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 16
URIs matter, not prefixes
• Many XML applications have recommended
prefixes. For example, SVG elements often use the
prefix svg and Resource Description Framework
(RDF) elements often have the prefix rdf. However,
these prefixes are simply conventions, and can be
changed based on necessity, convenience or whim.
• Before a prefix can be used, it must be bound to a
URI.
• These URIs are standardized, not the prefixes.
• The prefix can change as long as the URI stays the
same.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 17
The Default Namespace
• Indicates that an unprefixed element and all its unprefixed
descendant elements belong to a particular namespace by
attaching an xmlns attribute with no prefix:
<DATASCHEMA xmlns="http://www.w3.org/2000/P3Pv1">
<DATA name="vehicle.make" type="text" short="Make"
category="preference" size="31"/>
<DATA name="vehicle.model" type="text" short="Model"
category="preference" size="31"/>
<DATA name="vehicle.year" type="number" short="Year"
category="preference" size="4"/>
<DATA name="vehicle.license.state." type="postal." short="State"
category="preference" size="2"/>
<DATA name="vehicle.license.number" type="text" short="License
Plate Number" category="preference" size="12"/>
</DATASCHEMA>
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 18
The Default Namespace
• Both the DATASCHEMA and DATA
elements are in the
http://www.w3.org/2000/P3Pv1 namespace.

• Default namespaces apply only to elements,


not to attributes. The name, type, short,
category, and size attributes are not in any
namespace.

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 19
Multiple default namespaces
• You can change the default namespace within a particular element by adding an xmlns
attribute to the element.

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink">
<head><title>Three Namespaces</title></head>
<body> <h1 align="center">An Ellipse and a Rectangle</h1>
<svg xmlns="http://www.w3.org/2000/svg" width="12cm" height="10cm">
<ellipse rx="110" ry="130" />
<rect x="4cm" y="1cm" width="3cm" height="6cm" />
</svg>
<p xlink:type="simple" xlink:href="ellipses.html"> More about ellipses </p>
<p xlink:type="simple" xlink:href="rectangles.html"> More about rectangles
</p> <hr/> <p>Last Modified February 13, 2000</p>
</body>
</html>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 20
Parsers compare namespace URIs character
by character

These are three different namespaces:

– http://www.w3.org/1999/XSL/Transform

– http://www.w3.org/1999/XSL/Transform/

– http://www.w3.org/1999/XSL/Transform/index.ht
ml
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 21
Namespaces and Schemas

• URI matters; prefix doesn't

• Do not have to declare xmlns and


xmlns:prefix attributes

• Namespaces are used on elements and


attribute values, but not attribute names

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 22
A Song with a Namespace
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SONG xmlns="http://ibiblio.org/xml/namespace/song"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.cafeconleche.org/namespace/song
namespace_song.xsd" >
<TITLE>Hot Cop</TITLE>
<PHOTO ALT="Victor Willis in Cop Outfit" WIDTH="100" HEIGHT="200"/>
<COMPOSER>Jacques Morali</COMPOSER>
<COMPOSER>Henri Belolo</COMPOSER>
<COMPOSER>Victor Willis</COMPOSER>
<PRODUCER>Jacques Morali</PRODUCER>
<PUBLISHER>PolyGram Records</PUBLISHER>
<YEAR>1978</YEAR>
<ARTIST>Village People</ARTIST>
</SONG>
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 23
A Schema for a Document that Uses the Default
Namespace
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ibiblio.org/xml/namespace/song"
targetNamespace="http://ibiblio.org/xml/namespace/song"
elementFormDefault="qualified" attributeFormDefault="unqualified" >
<xsd:element name="SONG" type="SongType"/>
<xsd:complexType name="SongType">
<xsd:sequence>
<xsd:element name="TITLE" type="xsd:string"/>
<xsd:element name="PHOTO" type="PhotoType" minOccurs="0"/> <xsd:element
name="COMPOSER" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="PRODUCER" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="PUBLISHER" type="xsd:string" minOccurs="0"/>
<xsd:element name="YEAR" type="xsd:gYear"/>
<xsd:element name="ARTIST" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType> </xsd:schema>
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 24
Multiple Namespaces, Multiple Schemas
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SONG xmlns="http://www.cafeconleche.org/namespace/song"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.cafeconleche.org/namespace/song
xlink_song.xsd http://www.w3.org/1999/xlink xlink.xsd" >

<TITLE>Hot Cop</TITLE>
<PHOTO xlink:type="simple" xlink:href="hotcop.jpg" xlink:actuate="onLoad"
xlink:show="embed" ALT="Victor Willis in Cop Outfit" WIDTH="100"
HEIGHT="200"/>
<COMPOSER>Jacques Morali</COMPOSER>
<COMPOSER>Henri Belolo</COMPOSER>
<COMPOSER>Victor Willis</COMPOSER>
<PRODUCER>Jacques Morali</PRODUCER>
<PUBLISHER>PolyGram Records</PUBLISHER>
<YEAR>1978</YEAR>
<ARTIST>Village People</ARTIST>
</SONG>
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 25
XML Schemas

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 26
XML Schemas
„ “Schemas” is a general term--DTDs are a form of
XML schemas
… According to the dictionary, a schema is “a structured
framework or plan”
„ When we say “XML Schemas,” we usually mean
the W3C XML Schema Language
… This is also known as “XML Schema Definition”
language, or XSD

„ DTDs, XML Schemas are all XML schema


languages

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 27
Why XML Schemas?
„ DTDs provide a very weak specification language
… You can’t put any restrictions on text content
… You have very little control over mixed content (text
plus elements)
… You have little control over ordering of elements

„ DTDs are written in a strange (non-XML) format


… You need separate parsers for DTDs and XML
„ The XML Schema Definition language solves
these problems
… XSD gives you much more control over structure and
content
… XSD is written in XML

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 28
Why not XML schemas?
„ DTDs have been around longer than XSD
… Therefore they are more widely used
… Also, more tools support them

„ More advanced XML Schema instructions


can be non-intuitive and confusing

„ Nevertheless, XSD is not likely to go away


quickly
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 29
Referring to a schema
„ To refer to a DTD in an XML document, the reference goes
before the root element:
… <?xml version="1.0"?>
<!DOCTYPE rootElement SYSTEM "url">
<rootElement> ... </rootElement>
„ To refer to an XML Schema in an XML document, the
reference goes in the root element:
… <?xml version="1.0"?>
<rootElement
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
(The XML Schema Instance reference is required)
xsi:noNamespaceSchemaLocation="url.xsd">
(This is where your XML Schema definition can be found)
...
</rootElement>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 30
The XSD document
„ Since the XSD is written in XML, it can get
confusing which we are talking about
„ Except for the additions to the root element of
our XML data document, the rest of this lecture
is about the XSD schema document
„ The file extension is .xsd
„ The root element is <schema>
„ The XSD starts like this:
… <?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.rg/2001/XMLSchema">

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 31
<schema>
„ The <schema> element may have
attributes:
…xmlns:xs="http://www.w3.org/2001/XM
LSchema"
„ This is necessary to specify where all our
XSD tags are defined
…elementFormDefault="qualified"
„ This means that all XML elements must be
qualified
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 32
“Simple” and “complex” elements
„ A “simple” element is one that contains text and
nothing else
…A simple element cannot have attributes
… A simple element cannot contain other elements
… A simple element cannot be empty
… However, the text can be of many different types, and
may have various restrictions applied to it
„ If an element isn’t simple, it’s “complex”
…A complex element may have attributes
… A complex element may be empty, or it may contain
text, other elements, or both text and other elements

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 33
Defining a simple element
„ A simple element is defined as
<xs:element name="name" type="type" />
where:
… name is the name of the element
… the most common values for type are
xs:boolean xs:integer
xs:date xs:string
xs:decimal xs:time
„ Other attributes a simple element may have:
… default="default value" if no other value is specified
… fixed="value" no other value may be specified

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 34
Defining an attribute
„ Attributes themselves are always declared as
simple types
„ An attribute is defined as
<xs:attribute name="name" type="type" />
where:
… name and type are the same as for xs:element
„ Other attributes a simple element may have:
… default="default value" if no other value is specified
… fixed="value" no other value may be specified
… use="optional" the attribute is not required
(default)
… use="required" the attribute must be present
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 35
Restrictions, or “facets”
„ The general form for putting a restriction on a
text value is:
… <xs:element name="name"> (or xs:attribute)
<xs:restriction base="type">
... the restrictions ...
</xs:restriction>
</xs:element>
„ For example:
… <xs:element name="age">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0">
<xs:maxInclusive value="140">
</xs:restriction>
</xs:element>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 36
Restrictions on numbers
„ minInclusive -- number must be ≥ the given value
„ minExclusive -- number must be > the given value
„ maxInclusive -- number must be ≤ the given value
„ maxExclusive -- number must be < the given
value
„ totalDigits -- number must have exactly value
digits
„ fractionDigits -- number must have no more than
value digits after the decimal point
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 37
Restrictions on strings
„ length -- the string must contain exactly value characters
„ minLength -- the string must contain at least value characters
„ maxLength -- the string must contain no more than value characters
„ pattern -- the value is a regular expression that the string must match
„ whiteSpace -- not really a “restriction”--tells what to do with
whitespace
… value="preserve" Keep all whitespace
… value="replace" Change all whitespace characters to spaces
… value="collapse" Remove leading and trailing whitespace, and replace
all sequences of whitespace with a single space

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 38
Enumeration
„ An enumeration restricts the value to be one of
a fixed set of values
„ Example:
… <xs:element name="season">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Spring"/>
<xs:enumeration value="Summer"/>
<xs:enumeration value="Autumn"/>
<xs:enumeration value="Fall"/>
<xs:enumeration value="Winter"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 39
Complex elements
„ A complex element is defined as
<xs:element name="name">
<xs:complexType>
... information about the complex type...
</xs:complexType>
</xs:element>
„ Example:
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
„ <xs:sequence> says that elements must occur
in this order
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 40
Global and local definitions
„ Elements declared at the “top level” of a <schema> are available
for use throughout the schema
„ Elements declared within a xs:complexType are local to that type
„ Thus, in
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
the elements firstName and lastName are only locally declared
„ The order of declarations at the “top level” of a <schema> do not
specify the order in the XML data document

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 41
Declaration and use
„ So far we’ve been talking about how to
declare types, not how to use them
„ To use a type we have declared, use it as
the value of type="..."
… Examples:
„ <xs:element name="student" type="person"/>
„ <xs:element name="professor" type="person"/>

… Scope is important: you cannot use a type if is


local to some other type
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 42
xs:sequence
„ We’ve already seen an example of a
complex type whose elements must occur
in a specific order:
„ <xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName"
type="xs:string" />
<xs:element name="lastName" type="xs:string"
/>
</xs:sequence>
</xs:complexType>
</xs:element>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 43
xs:all
„ xs:all allows elements to appear in any order
„ <xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
„ Despite the name, the members of an xs:all
group can occur once or not at all
„ You can use minOccurs="n" and maxOccurs="n" to specify
how many times an element may occur (default
value is 1)
… In this context, n may only be 0 or 1
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 44
Referencing
„ Once you have defined an element or
attribute (with name="..."), you can refer to
it with ref="..."
„ Example:
… <xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
… <xs:element name="student" ref="person">
… Or just: <xs:element ref="person">

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 45
Text element with attributes
„ If a text element has attributes, it is no
longer a simple type
… <xs:element name="population">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:integer">
<xs:attribute name="year"
type="xs:integer">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
… </xs:element>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 46
Empty elements
„ Empty elements are (ridiculously) complex

„ <xs:complexType name="counter">
<xs:complexContent>
<xs:extension base="xs:anyType"/>
<xs:attribute name="count" type="xs:integer"/>
</xs:complexContent>
</xs:complexType>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 47
Mixed elements
„ Mixed elements may contain both text and
elements
„ We add mixed="true" to the xs:complexType
element
„ The text itself is not mentioned in the element,
and may go anywhere (it is basically ignored)

„ <xs:complexType name="paragraph" mixed="true">


<xs:sequence>
<xs:element name="someName" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 48
List:
<xsd:simpleType name='sizes'>
<xsd:list itemType=‘xsd:decimal'/>
</xsd:simpleType>

<dimension xsi:type='sizes'> 8 10.5 12 </dimension>

Union:
- it is a derived data type.
- it is not built-in data type.
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 49
Predefined string types
„ Recall that a simple element is defined as:
<xs:element name="name" type="type" />
„ Here are a few of the possible string types:
… xs:string-- a string
… xs:normalizedString -- a string that doesn’t contain
tabs, newlines, or carriage returns
… xs:token -- a string that doesn’t contain any
whitespace other than single spaces
„ Allowable restrictions on strings:
… enumeration, length, maxLength, minLength,
pattern, whiteSpace

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 50
Predefined date and time types
„ xs:date -- A date in the format CCYY-MM-
DD, for example, 2002-11-05
„ xs:time -- A date in the format hh:mm:ss
(hours, minutes, seconds)
„ xs:dateTime -- Format is CCYY-MM-
DDThh:mm:ss
„ Allowable restrictions on dates and times:
… enumeration, minInclusive, maxExclusive,
maxInclusive, maxExclusive, pattern,
whiteSpace
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 51
Predefined numeric types
• Here are some of the predefined numeric
types:
xs:decimal xs:positiveInteger
xs:byte xs:negativeInteger
xs:short xs:nonPositiveInteger
xs:int xs:nonNegativeInteger
xs:long
• Allowable restrictions on numeric types:
– enumeration, minInclusive, maxExclusive,
maxInclusive, maxExclusive, fractionDigits,
totalDigits, pattern, whiteSpace
Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 52
XSL
„ XSL is a family of recommendations for defining XML
document transformation and presentation. It consists of
three parts:
„ XSL Transformations (XSLT)
… a language for transforming XML
„ the XML Path Language (XPath)
… an expression language used by XSLT to access or refer to parts
of an XML document. (XPath is also used by the XML Linking
specification)
„ XSL Formatting Objects (XSL-FO)
… an XML vocabulary for specifying formatting semantics
„ An XSLT stylesheet specifies the presentation of a class
of XML documents by describing how an instance of the
class is transformed into an XML document that uses a
formatting vocabulary, such as (X)HTML or XSL-FO. For a
more detailed explanation of how XSL works, see the
What Is XSL page.

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 53
XSLT

„ An XSLT style sheet specifies the


presentation of a class of XML documents
by describing how an instance of the class
is transformed into an XML document that
uses a formatting vocabulary, such as
(X)HTML or XSL-FO. For a more detailed
explanation of how XSL works, see the
What Is XSL page.

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 54
In Summary…

ƒUnderstood the need and usage of XML in todays applications


ƒSyntax and semantics of the language
ƒDTD and XSD
ƒUsage of XSL
ƒSAX and DOM , their usage and implementations

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 55
The End

Teknoturf Info Services Pvt. Ltd. | © Copyright 2008 (Do not redistribute or reuse) Slide# 56