Module 1: Overview of XML and XSLT

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 20

Module 1: Overview of

XML and XSLT


Overview

Representing Data with XML


Transforming XML Documents with XSLT
Using XML and XSLT to Build Solutions
Representing Data with XML

Understanding XML Document Structure


Understanding Namespaces
Creating XML Documents
Using XML in Web Applications
Using XML in E-Commerce
Using XML for Application Integration
Demonstration: Representing Data with XML
Understanding XML Document Structure

<?xml version="1.0"?>
XML declaration <employees>xmlns="urn:nwtraders">
Document <employee>id="123" start="1997">
element <name></name>
Carol Philips</name>
<salary></salary>
145000</salary>
Elements </employee>
Attributes
<employee>id="456" start="2000">
Text content <name></name>
Mike Reid</name>
<salary></salary>
91000</salary>
Namespaces </employee>
</employees>
Understanding Namespaces

Namespaces use URIs, typically URNs or URLs


"urn:nwtraders"
"urn:nwtraders" "http://www.nwtraders.msft"
"http://www.nwtraders.msft"

To define a default namespace


Specify xmlns=a-namespace-URI
<employees
<employees xmlns="urn:nwtraders">
xmlns="urn:nwtraders">

To define a non-default namespace


Specify xmlns:a-prefix=a-namespace-URI
<lit:employees
<lit:employees xmlns:lit="urn:nwtraders">
xmlns:lit="urn:nwtraders">
Creating XML Documents

You can create XML documents from various sources

Legacy systems
XML
XML
document
document
Relational
databases

Active Server
Pages

Other XML documents Messages


Using XML in Web Applications

Use XML to communicate between a Web server and


a Web browser
Web server sends XML to the browser
Browser sends XML back to the Web server
Web browser Web server Data source
2 Catalog XML 1 Read catalog

Build XML 4 Order info XML 5 Update database


data packet
Using XML in E-Commerce

XML documents can be exchanged between


e-commerce trading partners
XML can be used to represent common business
documents in a standard format
Examples:
Purchase orders
Invoices
Payment notifications
Using XML for Application Integration

XML can be used to integrate diverse applications


Represent the data as XML
Represent routing information as XML
Benefits of using XML
Decreased coupling between applications
Support for publish/subscribe messaging
Neutrality
Demonstration: Representing Data with XML
Transforming XML Documents with XSLT

What Is an XSLT Style Sheet?


Using XSLT Capabilities
Transforming XML into HTML
Transforming XML into a Different XML Grammar
Demonstration: Transforming XML Documents
with XSLT
What Is an XSLT Style Sheet?

An XSLT style sheet transforms an XML document into


another format
A style sheet can create different types of output
documents:
An HTML document (using well-formed XML syntax)
Another XML document (different grammar)
A plain-text document
Using XSLT Capabilities

An XSLT style sheet can perform a wide range


of transformations
Examples:
Map one XML grammar to another
Filter unwanted data
Sort XML data
Restructure an XML document
Perform computations
Transforming XML into HTML

Transforming XML into HTML by using XSLT

XML
document
HTML document
XSLT
+ processor
(XML compliant)

XSLT
style sheet

<employees>
<employees> <HTML><TABLE>
<HTML><TABLE>
<employee>
<employee> <TR>
<TR>
<name>Reid</name>
<name>Reid</name> <TD>Reid</TD>
<TD>Reid</TD>
<salary>91000</salary>
<salary>91000</salary> <TD>91000</TD>
<TD>91000</TD>
</employee>
</employee> </TR>
</TR>

</employees>
</employees> </TABLE></HTML>
</TABLE></HTML>
Transforming XML into a Different XML Grammar

Transforming XML into a different grammar by using XSLT

XML
document
Different XML
XSLT
+ processor
grammar

XSLT
style sheet

<employees>
<employees> <staff>
<staff>
<employee>
<employee> <staff-member
<staff-member
<name>Reid</name>
<name>Reid</name> name="Reid"
name="Reid"
<salary>91000</salary>
<salary>91000</salary> pay="91000"/>
pay="91000"/>
</employee>
</employee>

</employees>
</employees> </staff>
</staff>
Demonstration: Transforming XML Documents with
XSLT
Using XML and XSLT in Practice

Northwind Web Site Overview


Demonstration: Using XML and XSLT in Practice
Northwind Web site Overview

Web browser and Web server communicate by using


XML
Catalog data, shopping basket, and orders
XML data is transformed by using XSLT
Transform into HTML for the browser
Transform into a different XML grammar
Demonstration: XML and XSLT Web Site Walk-
Through
Review

Representing Data with XML


Transforming XML Documents with XSLT
Using XML and XSLT to Build Solutions

You might also like