xml technology nizar mabroukeh [email protected] coe 445 kfupm – april, 2001

103
XML Technology Nizar Mabroukeh [email protected] COE 445 KFUPM – April, 2001

Post on 19-Dec-2015

236 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

XML Technology

Nizar [email protected]

COE 445KFUPM – April, 2001

Page 2: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 2

We will cover… What is XML? Components of an XML Document Document Type Definition (DTD) XML Data Islands Parsing XML and DOM XML presentation with CSS, XSL and XSLT XPath, XML and Database Integration Why use XML? Creating your own XML vocabulary Review of XML Applications and Tools XML Resources

Page 3: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

What is XML?

Page 4: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 4

Markup Languages SGML:

Standard Generalized Markup Language Mother of Markup Languages

HTML Most popular presentation language for web

XML: Draws heavily on the merits & shortcomings of

HTML & SGML

Page 5: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 5

Issues with HTMLMerits:

Very easy to use & learn Presentation technology It is the most popular

Shortcomings: NOT a data technology Poor Searching There is no Intelligence of content/data We loose meaning association with content Data cannot be represented hierarchically Limited set of tags

Page 6: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 6

How does XML look? Simple XML data would look like

<book>

<title> XML Tech </title>

<author> YAG </author>

<level> Freshman </level>

</book>

<book> : Called the root node

Page 7: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 7

XML HTML

Similar in appearance Both are based on SGML

BUT… XML describes data HTML displays data

Page 8: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

XML

(eXtensible Markup Language)

Page 9: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 9

What Is XML? “XML is a

platform-independent, self-describing, expandable, standard data exchange format that can be used either independently

or embedded and used within other

solutions.”

Page 10: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 10

Platform Independent Windows Unix Macintosh Mainframe

Page 11: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 11

Self-Describing Example:

<DATE>July 26, 1998</DATE>

Describes the information, not the presentation. Format flexible.

Page 12: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 12

Expandable = Extensible HTML has a fixed set of tags

<H1>, <B>, <PRE>

XML lets you have your own tags <dangerous-substance>,

<Shakespearean-character>, <cash-equivalent>

Page 13: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 13

Standard W3C (World Wide Web Consortium)

www.w3c.org

XML 1.0 specification was issued as standards-based text format for interchange of data as of February 1998.

W3C XML Working Group designed XML as a simplified subset of SGML

Page 14: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 14

Standard XML specification does not define

any particular tag names (like HTML), instead it defines general syntactic rules enabling developers to create their own domain-specific vocabularies of tags.

Page 15: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 15

balance sheet

total-assets

asset (current)

amount (1998)

$41,000,000

<balance-sheet><total-assets><asset-type="current">

<amount-period="1998"><amount>$41,000,000

</amount></amount-period>

</asset-type></total-assets>

</balance-sheet>

Context Greater context to the information Tree structure is natural in XML

Page 16: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 16

Freedom Extensible markup language

Customized tags

Tags give meaning to the content

Separates data from style

Page 17: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 17

Why XML? Derived as a subset of SGML Allows you to define your own tags

XML: <author> YAG </author>HTML: <B> YAG </B>

Provides meaningful & readable data Meaning searches can be performed Much simpler than SGML

SGML spec = 300 pages, XML = 33 pages Purely a Data Technology Supports compound documents.

Page 18: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 18

XML Advantages

Web based

Extensible

License-free

Platform independent

Single end-to-end IT solution for electronic information exchanges

Page 19: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

XML Documents

Authoring XML

Page 20: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 20

XML Elements An XML element is made up of a start tag, an

end tag, and data in between. The start and end tags describe the data within the tags, which is considered the value of the element.

For example, the following XML element is a <chairman> element with the value “Sadiq Sait"

<chairman>Sadiq Sait</chairman>

Elements can be empty, to represent an empty element: <chairman/>

Page 21: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

<book> Codebook 6.0 </book>

Opening Tag

Content Closing Tag

Element

Page 22: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 22

XML Attributes An element can optionally contain one or

more attributes. An attribute is a name-value pair separated by an equal sign (=).

Example: <CITY ZIP=“31261">Dhahran</CITY>

Here, ZIP=“31261" is an attribute of the <CITY> element. Attributes are used as meta information

Page 23: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 23

XML is…

…Case-sensitive

Page 24: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 24

Parts of an XML document

Version Declaration

Document Type Definition (DTD)

<root>

BODY

</root>

Page 25: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 25

Version Declaration

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

Encoding: Supports Unicode 8, Unicode 16 & Others In short: Provides for multi-lingual data

Standalone: Indicates whether the document has any

markup declarations that are external to the document

Page 26: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 26

XML data This is how XML data would look like (the

body of the document):

<books><book>

<name> Codebook 6.0 </name> <author> YAG </author> <level> Intermediate & Advanced </level>

</book><book>

<name> Jave for Beginners </name> <author> Dale </author> <level> Beginner </level>

</book></books>

Page 27: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 27

XML Document Rules ONE Root element

ALL tags start AND end

Tags cannot overlap and are case sensitive

Attribute values enclosed in quotes

Attributes not repeated in an element

FIRST item must be

<books>

<book></book>

<book ISBN=“21-458-65-0”>

<para id=“1” s:id=“4”>

<?xml version=“1.0”?>

Page 28: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 28

Two types of XML documents

Well-formed XML documents

Valid XML documents

Page 29: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 29

Well-formed document Must contain one or more elements Must contain a uniquely named root element All other elements within the root element must

be nested correctly An XML parser will reject malformed documents

(the method of rejection will vary by parser author)

Documents that contain XML and HTML tags are common

HTML within an XML document must be well-formed

Page 30: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 30

Valid XML document The XML document must be well formed Should contain a Document Type Definition

DTD is a schema which contains the constraints for the XML document

It contains Element definitions and their Attributes

Attributes should comply with the following rules Cannot contain <, & or a single ‘ or ‘’.

Elements must be nested correctly

Page 31: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 31

Document Type Definition DTD is a text document that defines

the lexicon of legal names for tags in a particular XML vocabulary

It also defines how tags should be nested

It can be written as code inside the XML file or specified externally as a separate text file with extension .dtd

Page 32: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 32

Sample DTD<!-- Uses EBNF (Extended Backus Naur Form) -->

<!DOCTYPE book [

<!ELEMENT book(name,author,level)+>

<!ELEMENT name(#PCDATA)>

<!ELEMENT author(#PCDATA)>

<!ELEMTNT level(#PCDATA)>

<!ATTLIST author email CDATA #IMPLIED>

]>

DTD may be specified externally with .dtd extension <!DOCTYPE book SYSTEM “book.dtd”>

Page 33: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 33

More on DTD Special software can help you build your

DTD document visually instead of having to write all this weird code, example software package is “XML Authority” from Extensibility

An XML document is associated with a corresponding DTD document for validation using the <!DOCTYPE…> tag

Page 34: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 34

Why use a DTD? Application independent way of

sharing data Industries or trading parties can agree

on a standard for interchanging data Verification that data received from

trading parties is valid.

Page 35: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 35

Complete XML document<?xml version=“1.0” ?>

<!DOCTYPE book [

<!ELEMENT book(name,author,level?)+>

<!ELEMENT name(#PCDATA)>

<!ELEMENT author(#PCDATA)>

<!ELEMTNT level(#PCDATA)>

]>

<book>

<name> Codebook 6.0 </name>

<author> YAG </author>

<level> Intermediate & Advanced </level>

</book>

Page 36: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 36

OR

<?xml version=“1.0” ?>

<!DOCTYPE book SYSTEM “book.dtd”>

<book>

<name> Codebook 6.0 </name>

<author> YAG </author>

<level> Intermediate & Advanced </level>

</book>

Page 37: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 37

XML Document Pluses Tightly Structured Extensible Easily models data Useful for applications and transfer

between applications Interchangeable

Page 38: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

XML Data Islands

XML inside HTML

Page 39: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 39

XML Data Islands A data island is an XML document that

exists within an HTML page. It allows you to script against the XML

document without having to load it through script or through the <OBJECT> tag.

Almost anything that can be in a well-formed XML document can be inside a data island

Page 40: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 40

How to create XML data island

The XML for a data island in HTML can be either:

Inline using ID,

or called from an outside xml file using SRC,

or created using a <script> tag

Page 41: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 41

Inline data island The <XML> element marks the beginning

of the data island, and its ID attribute provides a name that you can use to reference the data island.

<XML ID="XMLID"ID="XMLID"> <customer>

<name>Mark Hanson</name> <custID>81422</custID> </customer>

</XML>

Page 42: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 42

XML referenced from outside file

referenced through a SRC attribute on the <XML> tag:

<XML ID="XMLID" SRC="customer.xml"SRC="customer.xml"></XML>

Page 43: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 43

Created using <script> tag

<SCRIPT LANGUAGE="xml" ID="XMLID"LANGUAGE="xml" ID="XMLID"> <customer>

<name>Mark Hanson</name> <custID>81422</custID>

</customer> </SCRIPT >

Page 44: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

Parsing XML

Page 45: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 45

What is XML Parsing For a computer program to access the

structured information in the document in a meaningful way, parsing is required

The parser first reads the stream of characters and recognizes the syntactic details of elements, attributes and text in the document

Then, the parser exposes the hierarchical set of information in the document as a tree of related elements, attributes and text items

Page 46: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 46

The logical tree of information items created after parsing the XML document, is called the Information Set or Infoset

This can then be manipulated in different ways and data extracted for usage in applications, databases,…etc

Page 47: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 47

XML Parsers Always check for well-formedness Can be validating or non-validating Validation required association with DTD

document Included in Microsoft Internet Explorer 5.0 Language-neutral programming model By using W3C XML 1.0 and XML DOM it

supports JavaScript, VBScript, Java, C++, Perl

Page 48: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 48

Manipulating XML using the DOM

W3C provides a standard API called the Document Object Model (DOM) to access an XML document’s infoset

The DOM API provides a complete set of operations to programmatically manipulate the node tree including navigating the nodes in the hierarchy, creating and appending new nodes, removing nodes, etc.

Page 49: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 49

Once you are done with making changes to the node tree you can save it and serialize the infoset back into an XML document

xml infosetparsing

serialization

Page 50: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 50

DOM Properties & Methods An XML document object is created when an XML

data island is loaded and parsed…. and it has Properties & Methods

XMLDocument: Returns a reference to the XML DOM exposed by the object

documentElement: Returns the root element

childNodes: Returns a node list containing children (if any)

item(id): Access individual nodes through an index (zero based)

text Returns the text content of the node

Let’s look at an example…

Page 51: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 51

DOM Example<XML ID="xmlDocument"> <class> <student studentID="13429"> <name>Jane Smith</name> <GPA>3.8</GPA> </student> </class></XML>

All of the below begin with xmlDocument.documentElement.childNodes.item(0).childNodes.item(0).text Returns "James Smith".childNodes.item(1).text Returns "3.8".text Returns "James Smith 3.8" i.e. name & GPA

Note: Everything is case sensitive hereNote: Everything is case sensitive here

Data Island

Page 52: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

XML Presentation

Viewing XML

Page 53: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 53

Viewing XML Unlike HTML, XML does not predefine

display properties for specific elements.

C++ Data Source Object (DSO) Binds XML to HTML and gives better

performance, built in IE 5.0

Cascading Style Sheets (CSS)

Extended Stylesheet Language (XSL)

Page 54: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 54

CSS Separate file with a .css extension

object,+ {[property name]:[property value] ; + }

DIV {color:red; font-size:16pt}

/* Comments are entered the C way here */

Page 55: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 55

Displaying XML with CSS Modify the

presentation of XML Documents

Follow normal CSS syntax

Referenced in the XML source document

paragraph{ COLOR: red; FONT-FAMILY: 'Book Antiqua'; FONT-VARIANT: small-caps; FONT-WEIGHT: bolder}preamble{ COLOR: blue; FONT-FAMILY: 'Book Antiqua'; FONT-VARIANT: small-caps; FONT-WEIGHT: bolder}

<?xml-stylesheet type="text/css" href="const.css"?>

Page 56: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 56

XSL eXtended Stylesheet Language

Syntax is similar to XML

In fact, XSL is written in XML

Page 57: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 57

The aim of XSL is to provide a simple but powerful stylesheet syntax, which can be used to define how XML documents should appear on the screen.

An XSL stylesheet transforms an XML document into a suitable form for presentation

It allows us to control how and which parts of the documents should be shown to the user.

Page 58: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 58

The XSL processor takes an XML document as input, and translates it into a different XML document suitable for output. This resultant XML document can be passed through a separate tool to add the finishing touches ready for presentation.

Page 59: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 59

Displaying XML with XSL More powerful

than CSS XSL documents

are XML documents

<xsl:for-each select=“books/book" order-by=“author">

<TR VALIGN="top" > <TD>

<xsl:value-of select="name"/>

</TD><TD><xsl:value-of

select=“author"/></TD></TR>

</xsl:for-each>

Page 60: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 60

XSL Styling Tools

Page 61: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 61

XSL Style Sheet

DTD

XML Document

XM

L P

arse

r

XS

L P

roce

sso

r

Web Browser

Other(e.g. Directly into

Application

Integrated use of XML

Page 62: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 62

XSLT

eXtended Stylesheet Language for Transformations

Transforms XML from one tree-based structure to another

Page 63: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 63

Advantages of XSLT Convert between XML vocabularies

used by different applications

Present data from an XML document by transforming it into HTML, or another format that’s appropriate to the user or special device requesting the data

Page 64: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

Database Integration

Query and Search XML documents

Page 65: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 65

XPath

XML Path Language is a W3C standard

It is a declarative language

Used to interrogate an XML document to select subsets of information

Page 66: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 66

XPath provides a method for addressing parts of an XML document.

Allows string, number and boolean manipulation Treats XML document as set of nodes, allows matching

It is called a Path language because it is design like the path notation in URLs and files in directories

Page 67: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 67

XPath Example/MovieList/Movie/Cast/Actor/* returns all info about all actors

/MovieList/Movie/Cast/* returns all info about Cast including that of Director and Actor and

Actress

To find attributes instead of elements we use @

/MovieList/Movie/@Title returns titles of all movies

//Actress/@Role returns the Role of any Actresses anywhere in the document

Page 68: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 68

Find the Cast of any movies directed byMinghella with a running time greater than130 minutes:

/MoiveList/Movie[Director/Last=‘Manghella’ and @RunningTime >130]/Cast

Page 69: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 69

Where to Use XPath<Item Context="{Xpath here}" Type="">

<Label>Your Name</Label>

<Interface>

<EditableField Duid="{Xpath here}">

<Value>Tony</Value>

</EditableField> </Interface>

</Item>

Logical:

<TD NOWRAP="NOWRAP" ALIGN="LEFT">

<INPUT TYPE="text" SIZE="48" VALUE="Tony" Name="{Xpath here}"/>

</TD>

HTML:

Page 70: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 70

Using XPath Create an XPath for each unit of

information Carry the XPaths with the information as

it is transformed into other formats Use XPaths to link language strings and

labels with the information they describe

Generate an XSL stylesheet that uses the XPaths to generate the outgoing message

Page 71: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

You should be using XML

More reasons for you to use XML

Page 72: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 72

Why should I use XML XML enables a data web of

information services; it is vendor-neutral, platform-neutral, language-neutral technology

Simplifies application integration, consider the following example

Page 73: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 73

Simplifies Integration If a company has:

Machines running OS from Sun, HP, IBM… Databases from Oracle, IBM, Microsoft… Packaged applications from Oracle, SAP…

An XML-based representation of data and the HTTP protocol might be the only things these various systems can ever hope to have in common!

Especially if you want to integrate them over the Internet

Page 74: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 74

Why should I use XML XML also simplifies Information

Publishing and ReuseWith XML and XSLT you can easily:

• Separate data from presentation, allowing you to change the look of information without affecting application code

• Publish the same data using output styles specific to each kind of requesting device: browser, cell phone, PDA or another computer, etc.

Page 75: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 75

WML: Wireless Markup Language for cell phones and PDAs

SVG: Scalable Vector Graphics language for rendering rich, data-driven images

XSL Formatting Objects: for high-quality printed output

Page 76: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

Creating your own XML Vocabulary

Page 77: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 77

XML Vocabulary The set of XML elements and

attributes for a certain application is called an XML Vocabulary

Can be used in more than one XML document for the same application

Page 78: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 78

Create your own… Begin each document with an XML

decleration<?xml version=“1.0”?> (case-sensitive)

Use only one top-level document element cannot be repeated

Match opening and closing tags properly (notice case-sensetivity)

Page 79: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 79

Add comments between <!-- and --> characters

Start element and attribute names with a letter. Cannot contain spaces

Put attributes in the opening tag

Enclose attribute values in matching quotes

Page 80: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 80

Use only simple text as attribute values

Use &lt; and &amp; instead of < and & for literal less-than and ampersand characters

Write empty elements as <ElementName/>

If you follow these rules then your document will be a well-formed XML document

Page 81: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

Review of Applications and Tools

Page 82: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 82

XML Tools Help author the grammars (Schema,

Filter, Updates)

View, Edit & Manage XML

Define mappings between XML logical views & Databases.

Page 83: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 83

How is XML used? Publishing

Create once, use many Database Management

Database integration e-Business

Key driver

Page 84: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 84

XML Creation Tools

Two schools:

Data centric

Document centric

Page 85: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 85

Microsoft XML Notepad

Free Tree-

based Great

search

msdn.microsoft.com/xml/notepad

Page 86: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 86

CueSoft eXML Tree or

source view

Attribute handling

No search No nav bar

in source view

www.cuesoft.com

Page 87: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 87

Techno2000 Clip! Powerful Flexible Wizards DTD

creationhttp://www.t2000-usa.com/download/download_index.html

Page 88: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 88

Vervet Logic XML Pro More

expensive

                                 

                  

www.vervetlogic.com

Page 89: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 89

Document Oriented Examples

SoftQuad XMetaL Corel WordPerfect 9 Arbortext Adept Editor

Not as good for data development Require DTD or equivalent

Page 90: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 90

XSL Tester

Free Open

source VB

www.vbxml.com

Page 91: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 91

XML Authority from Extensibility

Page 92: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 92

XML Authority from Extensibility

DTDs

Schema

Page 93: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 93

Other Choices Web-based

DTD Generator• www.pault.com/Xmltube/dtdgen.html

IBM Suite Visual DTD Visual XML Transformation

Page 94: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 94

Utilities

File manipulation XML Junction

• www.xmljunction.com

ODBC2XML

Page 95: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 95

Security

IBM’s XML Security Suite www.alphaworks.ibm.com/tech/

xmlsecuritysuite

Page 96: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 96

Programming and XML

Programming tools and environments Java including JAXP Visual Basic (VB) and Visual

Basic for Applications (VBA) Databases and other tools

Document vs. event driven processing (DOM vs. SAX)

Page 97: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

Resources for XML

Page 98: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 98

Software Sources Interesting sites

www.xmlsoftware.com

alphaworks.ibm.com

www.garshol.priv.no/download/xmltools/std_ix.html

Page 99: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 99

WebSites

The Mother Ship www.w3c.org/xml

Heavy Stuff www.ibm.com/developer/xml msdn.microsoft.com/xml www.oracle.com/xml/ java.sun.com/xml/

Page 100: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 100

More Resources … XML Information sites

www.xmlinfo.com www.xml.com www.xml.org www.xmlelephant.com metalab.unc.edu/xml/ www.ucc.ie/xml/

XML Tutorials www.xml101.com

Page 101: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 101

More Resources … XSL Information

http://www.mulberrytech.com/xsl/xsl-list

VB XML Information mailto:[email protected]

Page 102: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 102

And finally… We’re only at the very start of the

Web revolution. XML is the fundamental building

block XML technology is moving forward,

and Standards are rapidly evolving

Page 103: XML Technology Nizar Mabroukeh nizar@ccse.kfupm.edu.sa COE 445 KFUPM – April, 2001

(c) Nizar Mabroukeh 2001 103

Thank You