good evening! dr. tappert and all our wonderful classmates!

55
Good Evening! Good Evening! Dr. Tappert and Dr. Tappert and all our wonderful all our wonderful classmates! classmates!

Upload: david-alexander

Post on 27-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Good Evening!Good Evening!

Dr. Tappert and all our Dr. Tappert and all our wonderful classmates!wonderful classmates!

XMLXML

George MathewGeorge Mathew

Elaine LiElaine Li

Lisa JordanLisa Jordan

Ping GallivanPing Gallivan

OverviewOverview

• A history lessonA history lesson– The Web and the birth of XML The Web and the birth of XML – when, why, and whowhen, why, and who

• What does XML give us?What does XML give us?

• Examples, illustrations, and applicationsExamples, illustrations, and applications

• The futureThe future

In The Beginning ..... In The Beginning ..... • ……. was the birth of the Web . was the birth of the Web

(Tim Berners-Lee, 1992) (Tim Berners-Lee, 1992)

Internetcommunication

protocols

EmailNewsFtp

HTML(data/display)

Hello ThereHere’s a zippy HTML page, with lots of Colors and Links ...!!!Fun, Eh?

• HTMLWeb

Server

HTTP(transfer)

Db & other

software

• HTTP

URLs(location

e.g -- http://www.foo.org/boo.html )

• URL

The Birth of XML...The Birth of XML...

• ..happened in 1996, when a group of experts assembled to try and find ..happened in 1996, when a group of experts assembled to try and find a way out of the problem.a way out of the problem.

• First draft came out in late 1996 ... Final version of the XML 1.0 First draft came out in late 1996 ... Final version of the XML 1.0 specification came out in February 1998 specification came out in February 1998

Core PrinciplesCore Principles

– SimpleSimple

But as not simple as HTML, in particular with stricter formal sytaxBut as not simple as HTML, in particular with stricter formal sytax

– ExtensibleExtensible

– Distributed environmentDistributed environment -friendly-friendly

What is XML?What is XML?

• XML stands for Extensible Markup LanguageXML stands for Extensible Markup Language• XML is a markup language much like HTMLXML is a markup language much like HTML• XML was designed to describe dataXML was designed to describe data• XML tags are not predefined in XML. You must define your XML tags are not predefined in XML. You must define your

own tags. own tags. Openingtags <tagname>Openingtags <tagname>

Closingtags</tagname>Closingtags</tagname>

• XML is self describing.XML is self describing.• XML uses a DTD(Document Type Definition) or a Schema to XML uses a DTD(Document Type Definition) or a Schema to

formally describe the data.formally describe the data.

XML vs HTMLXML vs HTML

• XML is not a replacement for HTML.XML is not a replacement for HTML.• XML and HTML were designed with different XML and HTML were designed with different

goals.goals.• XML was designed to describe data and to focus XML was designed to describe data and to focus

on what data is.on what data is.• HTML was designed to display data and to focus HTML was designed to display data and to focus

on how data looks.on how data looks.• HTML is about displaying information, XML is HTML is about displaying information, XML is

about describing information.about describing information.

Different XML varietiesDifferent XML varieties

VoiceXMLVoiceXML: Voice Applications: Voice Applications WMLWML: W: Wireless Markup Languageireless Markup Language MathMLMathML: : Mathematics domainMathematics domain XformsXforms: F: Forms to be filled outorms to be filled out XML QueryXML Query: A: Asking information of databasessking information of databases XMLSchemaXMLSchema: : XML "dialect"XML "dialect" XSLTXSLT: : Extensible Style Sheet TranslationsExtensible Style Sheet Translations XpathXpath: : "root" of a document down the document "root" of a document down the document

"tree""tree"

Why XML is so important….Why XML is so important….

• Many standard bodies are working on or have completed work on XML dialects for different industries.

• The academic community to standardize XML dialects for Math, Physics, Chemistry, Engineering, and Social Sciences as well.

Defining Specific Language Defining Specific Language Dialects……Dialects……

• Two ways of doing so:Two ways of doing so:

– XML Document Type Declaration XML Document Type Declaration (DTD)(DTD) -- Part of core XML spec. -- Part of core XML spec.

– XML SchemaXML Schema -- New XML specification -- New XML specification (2001), stronger constraints on XML (2001), stronger constraints on XML documents. documents.

Defining Specific Language Defining Specific Language DialectsDialects

• Adding dialect specifications implies two classes Adding dialect specifications implies two classes of XML data:of XML data:– Well-formedWell-formed An XML document that is An XML document that is

syntactically correctsyntactically correct– ValidValid An XML document that is both well-An XML document that is both well-

formed formed and and consistent with a specific DTD (or consistent with a specific DTD (or Schema) Schema)

• Most current dialects defined using DTDs. Most current dialects defined using DTDs. • Schemas often used for Schemas often used for type validationtype validation. .

XML (and related) SpecificationsXML (and related) Specifications

XML 1.0 XML names

‘Open’ std

W3C rec

W3C draft

industry std

XML Core

APIs

Style Protocols Web Services Application areas Data/presentaion

XHTMLbasic

Xlink …...

SAX 1

Xpath

XSLT

XSL

DOM 1

Modularized XHTML

Xforms

Canonical

XMLsignature

XML baseXpointer

XML query ….

Infoset

XML schema

Xfragment

XHTMLevents

UDDI

XML-RPC100's

more ....

SAX 2

DOM 2

DOM 3

CSS 1

CSS 2

CSS 3

JDOM

JAXP

WSDL ...

ebXML

Biztalk

WDDXXMI ...

...

IFX

Docbook

...

MathML

SMIL 1 & 2

VoiceXML

XHTML 1.0

RDF

SOAP RSS

CellML

IMS

SVG

HEML

TEI

XULJabber

Classes of use for XML….Classes of use for XML….

For machine-machine communicationFor machine-machine communication– Financial information exchangeFinancial information exchange

• FpML, FinXML, OFX/IFX, FixML, GOLD, XBRL, SwiftMLFpML, FinXML, OFX/IFX, FixML, GOLD, XBRL, SwiftML

– Directory services metadataDirectory services metadata• dirXML, DSML (Directory Services Markup Language), ….dirXML, DSML (Directory Services Markup Language), ….

– Other business transactionsOther business transactions• FRML (first retail markup language), …. ebXML (generic FRML (first retail markup language), …. ebXML (generic

business)business)

– News, data syndication (exchanging data between News, data syndication (exchanging data between machines)machines)

• XMLnews, ICE, NewsML, RSS, WDDX XMLnews, ICE, NewsML, RSS, WDDX

Classes of use for XMLClasses of use for XML

Manage the connection between machinesManage the connection between machines – Control of machine-machine applications Control of machine-machine applications

• XML-RPC, SOAPXML-RPC, SOAP

– Brokering of Web "Services"Brokering of Web "Services"• Biztalk, UDDI, ebXMLBiztalk, UDDI, ebXML

XML Messaging + ProcessingXML Messaging + Processing

FactorySupplier

Supplier

Supplier

Place order(XML/edi) using SOAP

Response(XML/edi) using SOAP

SOAP interface

XML Software…XML Software…

• XML parserXML parser -- Reads in XML data, checks for -- Reads in XML data, checks for syntactic (and possibly DTD/Schema) constraints, syntactic (and possibly DTD/Schema) constraints, and makes data available to an application. There and makes data available to an application. There are three 'generic' parser APIsare three 'generic' parser APIs– SAXSAX Simple API to XML (event-based)Simple API to XML (event-based)

– DOMDOM Document Object Model (object/tree based)Document Object Model (object/tree based)

– JDOMJDOM Java Document Object Model (object/tree Java Document Object Model (object/tree based)based)

XML Processing: SAX…XML Processing: SAX…

A) SAX: Simple API for XMLA) SAX: Simple API for XML– An An event-basedevent-based interface interface– Parser reports events whenever it sees a Parser reports events whenever it sees a

tag/attribute/text node/othertag/attribute/text node/other– Programmer attaches “event handlers” to handle Programmer attaches “event handlers” to handle

the eventthe event

XML Processing: SAXXML Processing: SAX

• AdvantagesAdvantages– Simple to useSimple to use– Very fast (not doing very much before you get the tags and Very fast (not doing very much before you get the tags and

data)data)– Low memory use (doesn’t read an XML document entirely into Low memory use (doesn’t read an XML document entirely into

memory)memory)

• DisadvantagesDisadvantages– Not doing very much for you -- you have to do everything Not doing very much for you -- you have to do everything

yourselfyourself– Not useful if you have to dynamically modify the document Not useful if you have to dynamically modify the document

once it’s in memory (since you’ll have to do all the work to put once it’s in memory (since you’ll have to do all the work to put it in memory yourself!)it in memory yourself!)

XML Processing: DOM…XML Processing: DOM…

B) DOM: Document Object ModelB) DOM: Document Object Model– An An object-oriented object-oriented interfaceinterface– Parser generates an Parser generates an in-memory treein-memory tree

corresponding to the documentcorresponding to the document– DOM interface defines methods for accessing DOM interface defines methods for accessing

and modifying the treeand modifying the tree

XML Processing: DOMXML Processing: DOM

AdvantagesAdvantages– Very useful for dynamic modification of, access to the treeVery useful for dynamic modification of, access to the tree– Useful for querying (I.e. looking for data) that depends on the Useful for querying (I.e. looking for data) that depends on the

tree structure tree structure element.childNode("2").getAttributeValue("boobie")]element.childNode("2").getAttributeValue("boobie")]

- Same interface for many programming languages (C++, Same interface for many programming languages (C++, Java, ...)Java, ...)

DisadvantagesDisadvantages– Can be slow (needs to produce the tree), and can take up lots Can be slow (needs to produce the tree), and can take up lots

of memoryof memory– DOM programming interface is a bit awkward, not terribly DOM programming interface is a bit awkward, not terribly

object orientedobject oriented

XML Processing: JDOM…XML Processing: JDOM…

C) JDOM: C) JDOM: JavaJava Document Object Model Document Object Model– A Java-specific A Java-specific object-oriented object-oriented interfaceinterface– Parser generates an in-memory tree Parser generates an in-memory tree

corresponding to the documentcorresponding to the document– JDOM interface has methods for accessing and JDOM interface has methods for accessing and

modifying the treemodifying the tree

XML Processing: JDOMXML Processing: JDOM

• AdvantagesAdvantages– Very useful for dynamic modification of the treeVery useful for dynamic modification of the tree– Useful for querying (I.e. looking for data) that depends on the Useful for querying (I.e. looking for data) that depends on the

tree structuretree structure– Much nicer Object Oriented programming interface than DOMMuch nicer Object Oriented programming interface than DOM

• DisadvantagesDisadvantages– Can be slow (make that tree...), and can take up lots of Can be slow (make that tree...), and can take up lots of

memorymemory– New, and not entirely cooked (but close) New, and not entirely cooked (but close) – Only works with Java, and not (yet) part of Core Java standardOnly works with Java, and not (yet) part of Core Java standard

What are XML Schemas?What are XML Schemas?

• Data ModelData Model• With XML Schemas you specify how your XML data will be With XML Schemas you specify how your XML data will be

organized, and the datatypes of your data. That is, with XML Schemas organized, and the datatypes of your data. That is, with XML Schemas you model how your data is to be represented in an instance document.you model how your data is to be represented in an instance document.

• A ContractA Contract• Organizations agree to structure their XML documents in conformance Organizations agree to structure their XML documents in conformance

with an XML Schema. Thus, the XML Schema acts as a contract with an XML Schema. Thus, the XML Schema acts as a contract between the organizations.between the organizations.

• A rich source of metadataA rich source of metadata• An XML Schema document contains lots of data about the data in the An XML Schema document contains lots of data about the data in the

XML instance documents, such as the datatype of the data, the data's XML instance documents, such as the datatype of the data, the data's range of values, how the data is related to another piece of data range of values, how the data is related to another piece of data (parent/child, sibling relationship), i.e., XML Schemas contain (parent/child, sibling relationship), i.e., XML Schemas contain metadatametadata

Elements Attributes and TypesElements Attributes and Types

The basic building blocks of XML Schemas are The basic building blocks of XML Schemas are Elements Elements

AttributesAttributesData types define the valid content that elements and Data types define the valid content that elements and

attributes contain. When you create XML schemas, attributes contain. When you create XML schemas, you define the individual elements and attributes and you define the individual elements and attributes and assign valid types to them. Elements describe data, assign valid types to them. Elements describe data, whereas attributes are like properties of an element,whereas attributes are like properties of an element,

  

Limitations of DTDsLimitations of DTDs

• DTD itself is not in XML format – more work for DTD itself is not in XML format – more work for parsersparsers

• Does not express data types(weak data typing)Does not express data types(weak data typing)• No namespace supportNo namespace support• Document can override external DTDDocument can override external DTD• No DOM supportNo DOM support• XML Schema is intended to resolve these issues XML Schema is intended to resolve these issues

but…DTDs are going to be around for a whilebut…DTDs are going to be around for a while

Let's see an exampleLet's see an example

• Convert the BookStore.dtd (next page) to Convert the BookStore.dtd (next page) to the XML Schema syntaxthe XML Schema syntax– for this first example we will make a straight, for this first example we will make a straight,

one-to-one conversion, i.e., Title, Author, Date, one-to-one conversion, i.e., Title, Author, Date, ISBN, and Publisher will hold strings, just like ISBN, and Publisher will hold strings, just like is done in the DTDis done in the DTD

– We will gradually modify the XML Schema to We will gradually modify the XML Schema to use stronger typesuse stronger types

BookStore.dtdBookStore.dtd

<!ELEMENT BookStore (Book)+><!ELEMENT Book (Title, Author, Date, ISBN, Publisher)><!ELEMENT Title (#PCDATA)><!ELEMENT Author (#PCDATA)><!ELEMENT Date (#PCDATA)><!ELEMENT ISBN (#PCDATA)><!ELEMENT Publisher (#PCDATA)>

ATTLISTELEMENT

ID

#PCDATA

NMTOKEN

ENTITY

CDATA

BookStore

BookTitle

Author

Date

ISBNPublisher

This is the vocabulary that DTDs provide to define yournew vocabulary

elementcomplexType

schema

sequence

http://www.w3.org/2001/XMLSchema

string

integer

boolean

BookStore

BookTitle

Author

Date

ISBNPublisher

http://www.books.org (targetNamespace)

This is the vocabulary that XML Schemas provide to define yournew vocabulary

One difference between XML Schemas and DTDs is that the XML Schema vocabularyis associated with a name (namespace). Likewise, the new vocabulary that you define must be associated with a name (namespace). With DTDs neither set ofvocabulary is associated with a name (namespace) [because DTDs pre-dated namespaces].

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>

BookStore.xsd (see example01)xsd = Xml-Schema Definition

(explanations onsucceeding pages)

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>

<!ELEMENT Title (#PCDATA)><!ELEMENT Author (#PCDATA)><!ELEMENT Date (#PCDATA)><!ELEMENT ISBN (#PCDATA)><!ELEMENT Publisher (#PCDATA)>

<!ELEMENT Book (Title, Author, Date, ISBN, Publisher)>

<!ELEMENT BookStore (Book)+>

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>

All XML Schemas have"schema" as the rootelement.

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>

The elements anddatatypes thatare used to constructschemas - schema - element - complexType - sequence - stringcome from the http://…/XMLSchemanamespace

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Book" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Book"> <xsd:complexType> <xsd:sequence> <xsd:element ref="Title" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Author" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Date" minOccurs="1" maxOccurs="1"/> <xsd:element ref="ISBN" minOccurs="1" maxOccurs="1"/> <xsd:element ref="Publisher" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/></xsd:schema>

Says that theelements definedby this schema - BookStore - Book - Title - Author - Date - ISBN - Publisherare to go in thisnamespace

Referencing a schema in an XML Referencing a schema in an XML instance documentinstance document

<?xml version="1.0"?><BookStore xmlns ="http://www.books.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.books.org BookStore.xsd"> <Book> <Title>My Life and Times</Title> <Author>Paul McCartney</Author> <Date>July, 1998</Date> <ISBN>94303-12021-43892</ISBN> <Publisher>McMillin Publishing</Publisher> </Book> ...</BookStore>

1. First, using a default namespace declaration, tell the schema-validator that all of the elementsused in this instance document come from the Book namespace.

2. Second, with schemaLocation tell the schema-validator that the http://www.books.org namespace is defined by BookStore.xsd (i.e., schemaLocation contains a pair of values).

3. Third, tell the schema-validator that the schemaLocation attribute we are using is the one inthe XMLSchema-instance namespace.

1

2

3

Note multiple levels of checkingNote multiple levels of checking

BookStore.xml BookStore.xsd XMLSchema.xsd(schema-for-schemas)

Validate that the xml documentconforms to the rules describedin BookStore.xsd

Validate that BookStore.xsd is a validschema document, i.e., it conformsto the rules described in theschema-for-schemas

<xsd:complexType> or <xsd:complexType> or <xsd:simpleType>?<xsd:simpleType>?

• When do you use the complexType element When do you use the complexType element and when do you use the simpleType and when do you use the simpleType element?element?– Use the complexType element when you want Use the complexType element when you want

to define child elements and/or attributes of an to define child elements and/or attributes of an elementelement

– Use the simpleType element when you want to Use the simpleType element when you want to create a new type that is a refinement of a built-create a new type that is a refinement of a built-in type (string, date, gYear, etc)in type (string, date, gYear, etc)

Built-in DatatypesBuilt-in Datatypes

• Primitive DatatypesPrimitive Datatypes– stringstring– booleanboolean– decimaldecimal– floatfloat– doubledouble– durationduration– dateTimedateTime– timetime– datedate– gYearMonthgYearMonth– gYeargYear– gMonthDaygMonthDay

• Atomic, built-inAtomic, built-in– ""Hello WorldHello World""– {{truetrue, , falsefalse}}– 7.087.08– 12.56E312.56E3, , 1212, , 1256012560,, 0 0, , -0-0, , INFINF, , -INF-INF, , NANNAN – 12.56E312.56E3, , 1212, , 1256012560,, 0 0, , -0-0, , INFINF, , -INF-INF, , NANNAN – P1Y2M3DT10H30M12.3SP1Y2M3DT10H30M12.3S– format:format: CCYY-MM-DDThh-mm-ssCCYY-MM-DDThh-mm-ss

– format:format: hh:mm:ss.ssshh:mm:ss.sss

– format:format: CCYY-MM-DDCCYY-MM-DD

– format:format: CCYY-MMCCYY-MM

– format:format: CCYYCCYY

– format:format: MM-DDMM-DD

Note: 'T' is the date/time separator INF = infinity NAN = not-a-number

Built-in Datatypes (cont.)Built-in Datatypes (cont.)

• Derived typesDerived types

– negativeIntegernegativeInteger

– longlong

– int int

– shortshort

– bytebyte

– nonNegativeIntegernonNegativeInteger

– unsignedLongunsignedLong

– unsignedIntunsignedInt

– unsignedShortunsignedShort

– unsignedByteunsignedByte

– positiveIntegerpositiveInteger

• Subtype of primitive datatypeSubtype of primitive datatype

– negative infinity to -1negative infinity to -1

– -9223372036854775808-9223372036854775808 toto 9223372036854775808 9223372036854775808

– -2147483648-2147483648 toto 21474836472147483647

– -32768-32768 toto 3276732767

– -127-127 toto 128128

– 0 to infinity0 to infinity

– 00 toto 1844674407370955161518446744073709551615

– 00 toto 42949672954294967295

– 00 toto 6553565535– 00 toto 255255

– 1 1 to infinityto infinity

Do Lab 3

Note: the following types can only be used with attributes (which we will discuss later): ID, IDREF, IDREFS, NMTOKEN, NMTOKENS, ENTITY, and ENTITIES.

Creating your own DatatypesCreating your own Datatypes

• A new datatype can be defined from an existing datatype A new datatype can be defined from an existing datatype (called the "base" type) by specifying values for one or (called the "base" type) by specifying values for one or more of the optional more of the optional facets facets for the base type.for the base type.

• Example. The string primitive datatype has six optional Example. The string primitive datatype has six optional facets:facets:– lengthlength– minLengthminLength– maxLengthmaxLength– patternpattern– enumerationenumeration– whitespace (legal values: preserve, replace, collapse)whitespace (legal values: preserve, replace, collapse)

Example of Creating a New Example of Creating a New Datatype by Specifying Facet ValuesDatatype by Specifying Facet Values

<xsd:simpleType name="TelephoneNumber"> <xsd:restriction base="xsd:string"> <xsd:length value="8"/> <xsd:pattern value="\d{3}-\d{4}"/> </xsd:restriction></xsd:simpleType>

1. This creates a new datatype called 'TelephoneNumber'. 2. Elements of this type can hold string values, 3. But the string length must be exactly 8 characters long and 4. The string must follow the pattern: ddd-dddd, where 'd' represents a 'digit'. (Obviously, in this example the regular expression makes the length facet redundant.)

1

2

3

4

Another ExampleAnother Example

<xsd:simpleType name="US-Flag-Colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="red"/> <xsd:enumeration value="white"/> <xsd:enumeration value="blue"/> </xsd:restriction></xsd:simpleType>

This creates a new type called US-Flag-Colors.An element declared to be of this typemust have either the value red, or white, or blue.

Annotating SchemasAnnotating Schemas

• The <annotation> element is used for documenting the schema, both The <annotation> element is used for documenting the schema, both for humans and for programs.for humans and for programs.– Use <documentation> for providing a comment to humansUse <documentation> for providing a comment to humans– Use <appinfo> for providing a comment to programsUse <appinfo> for providing a comment to programs

• The content is any well-formed XMLThe content is any well-formed XML

• Note that annotations have no effect on schema validationNote that annotations have no effect on schema validation

<xsd:annotation> <xsd:documentation> The following constraint is not expressible with XML Schema: The value of element A should be greater than the value of element B. So, we need to use a separate tool (e.g., Schematron) to check this constraint. We will express this constraint in the appinfo section (below). </xsd:documentation> <xsd:appinfo> <assert test="A &gt; B">A should be greater than B</assert> </xsd:appinfo><xsd:/annotation>

<?xml version="1.0"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> <xsd:element name="BookStore"> <xsd:complexType> <xsd:sequence> <xsd:element name="Book" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="Title" type="xsd:string"/> <xsd:element name="Author" type="xsd:string"/> <xsd:element name="Date" type="xsd:string"/> <xsd:element name="ISBN" type="xsd:string"/> <xsd:element name="Publisher" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:schema>

Can putannotationsonly at theselocations

What is VoiceXML?What is VoiceXML?

VoiceXML is a XML based language for VoiceXML is a XML based language for creating voice-user interfaces, particularly creating voice-user interfaces, particularly for the telephone. It uses speech for the telephone. It uses speech recognition and touchtone (DTMF keypad) recognition and touchtone (DTMF keypad) for input, and pre-recorded audio and text-for input, and pre-recorded audio and text-to-speech synthesis (TTS) for output. to-speech synthesis (TTS) for output.

HistoryHistory of VXML of VXML

• VoiceXML has its roots in a research project called VoiceXML has its roots in a research project called PhoneWeb at AT&T Bell Laboratories. PhoneWeb at AT&T Bell Laboratories.

• Motorola embraced the markup approach as a way Motorola embraced the markup approach as a way to provide mobile users with up-to-the-minute to provide mobile users with up-to-the-minute information and interactions. information and interactions.

• In October 1998, the World Wide Web In October 1998, the World Wide Web Consortium (W3C) sponsored a workshop on Consortium (W3C) sponsored a workshop on Voice Browsers. A number of leading companies, Voice Browsers. A number of leading companies, including AT&T, IBM, Lucent, Microsoft, including AT&T, IBM, Lucent, Microsoft, Motorola, and Sun, participated.Motorola, and Sun, participated.

Scope of VXMLScope of VXML

• VoiceXML use:VoiceXML use:-As a way to voice-enable a Web site, or -As a way to voice-enable a Web site, or

-As an open-architecture solution for -As an open-architecture solution for building building next-generation interactive voice next-generation interactive voice

response response telephone services.telephone services.

• One popular type of application is the One popular type of application is the voice voice portalportal, a telephone service where callers dial , a telephone service where callers dial a phone number to retrieve informationa phone number to retrieve information

Future of VoiceXMLFuture of VoiceXML

• Voice-enabled web is in demandVoice-enabled web is in demand

• Reduces costs Reduces costs

• Opens up new opportunities for Opens up new opportunities for businessbusiness

XML Advantages…..XML Advantages…..

• Self-describing, i.e., its tags are meaningful.Self-describing, i.e., its tags are meaningful.

• Extensible in many ways: extensible tag Extensible in many ways: extensible tag library, extensible document structure, and library, extensible document structure, and extensible document elements.extensible document elements.

• Distributable because its elements can be Distributable because its elements can be distributed entities in the web.distributed entities in the web.

XML Advantages….XML Advantages….

• User-friendly because it is human-readable.User-friendly because it is human-readable.• Web-friendly because its components can be Web-friendly because its components can be

drawn for various sources in the web. For example, drawn for various sources in the web. For example, data came from one source, stylesheet from second data came from one source, stylesheet from second source, and DTD from third source.source, and DTD from third source.

• Very suitable for manipulation by the object-Very suitable for manipulation by the object-oriented language because each XML element is an oriented language because each XML element is an object entity.object entity.

XML Disadvantages…XML Disadvantages…

• Size:Size: XML documents occupy more space than XML documents occupy more space than

binary representations due to the use of text for binary representations due to the use of text for

everything and the presence of the tags.everything and the presence of the tags.

• Performance:Performance: It takes more work to read and write It takes more work to read and write

XML documents than binary formats.XML documents than binary formats.

• Complexity:Complexity: Reading an XML document is more Reading an XML document is more

complicated than reading a fixed-format binary complicated than reading a fixed-format binary

document due to the tag processing that must occur.document due to the tag processing that must occur.

XML DisadvantagesXML Disadvantages

• More difficult, demanding, and precise than More difficult, demanding, and precise than HTMLHTML

• Lack of browser support/end user Lack of browser support/end user applicationsapplications

• XML requires a processing applicationXML requires a processing application

• XML is comparatively newXML is comparatively new

Future of XMLFuture of XML

To serve as an alternative to HTMLTo serve as an alternative to HTML Use in a variety of special-purpose Use in a variety of special-purpose

facilities, such as CDF, OSD, ICE ,RDF.facilities, such as CDF, OSD, ICE ,RDF. Data transmission and data manipulation Data transmission and data manipulation

over the web.over the web.

SummarySummary

• XML is a self-describing meta dataXML is a self-describing meta data

• DOCTYPE defines the DOCTYPE defines the root root element and element and location of DTDlocation of DTD

• Document Type Definition(DTD) defines Document Type Definition(DTD) defines the grammar of the documentthe grammar of the document

• DTD processing is expensiveDTD processing is expensive

• Schema uses XML to specify the grammarSchema uses XML to specify the grammar

Thank you!Thank you!

Good Night!Good Night!