21
XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Embed Size (px)

Citation preview

Page 1: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

XML, XSL, and SOAP

Building Object Systems from Documents

CSC/ECE 591oSummer 2000

Page 2: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

New Web Technologies Technologies under development by the

World Wide Web Consortium (W3C) See http://www.w3.org

Standards for Web-based documents XML: Extensible Markup Language XSL: Extensible Stylesheet Language SOAP: Simple Object Access Protocol Other technologies: XML Pointer, XML

Fragments, XML Schema, Resource Description Framework (RDF)…

Page 3: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

XML, the Extensible Markup Language Structured meta-data language

Derived from SGML (Simple Generalized Markup Language)

Same heritage as HTML, so looks similar

Used to describe any type of information in a machine-readable way

Page 4: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Components of XML DTD (Document Type Definition)

Description of valid XML document syntax (elements and structure)

Element XML document component Example: <NAME> … </NAME> Example: <YES/>

CDATA: Text inside an element Comments: <!-- blah blah blah --> Tags: <TAG>, </TAG>, <TAG/> Processing instructions: <!pi>

Page 5: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Example XML Document

<?xml version="1.0"?>

<!DOCTYPE greeting SYSTEM "hello.dtd">

<greeting>Hello, world!</greeting>

Page 6: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Example DTD

<!ELEMENT greeting (#PCDATA)>

Page 7: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

A More Complex DTD

<!ELEMENT doc (title, chapter*)>

<!ELEMENT chapter (title, (para|note)*, section*)>

<!ELEMENT section (title, (para|note)*)>

<!ELEMENT title (#PCDATA|emph)*>

<!ELEMENT para (#PCDATA|emph)*>

<!ELEMENT note (#PCDATA|emph)*>

<!ELEMENT emph (#PCDATA|emph)*>

Page 8: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

XSL – Extensible Stylesheet Language XSL is a language for expressing

stylesheets (XSL:T) A language for transforming XML

documents An XML vocabulary for specifying formatting

semantics (under development) An XSL 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 the formatting vocabulary

Page 9: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Thinking of XSL Model the XML document as a “tree” XSL document is a list of node

“patterns” and “actions” Search XML tree for matching

patterns and apply corresponding actions

Result is target document

Page 10: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

A Simple XSL Example<xsl:stylesheet version="1.0“

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns="http://www.w3.org/TR/xhtml1/strict">

<xsl:template match="doc/title">

<h1>

<xsl:apply-templates/>

</h1>

</xsl:template>

</xsl:stylesheet>

Page 11: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Applying the Example<!DOCTYPE doc SYSTEM "doc.dtd">

<doc>

<title>Document Title</title>

<chapter>

<title>Chapter Title</title>

</chapter>

</doc> <?xml version="1.0" encoding="iso-8859-1"?><html xmlns="http://www.w3.org/TR/xhtml1/strict"><h1>Document Title</h1><doc> <chapter> <title>Chapter Title</title> </chapter></doc>

Page 12: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Defining an “area” of the Tree Types of relationships

Child Sibling Parent Descendant Ancestor Root

Page 13: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Examples of Template Matching para (element match) * (any element) chapter|appendix (either/or) olist/item (parent/child) appendix//para (ancestor/child) / (root) id(“W11”) (any node with ID W11) para[1] (para element that is first child) para[last()=1] (only para child) para[position()>1] (not first para child) para[position() mod 2=1] (odd numbered child

para)

Page 14: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Content Generation Among the things you can do:

Generate numbered lists Create XML processing instructions Apply variables and dynamic values Create comments Sort

Page 15: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Uses of XSL Convert XML data

Into HTML, WML, VoiceXML, etc. One XSL document per target format Single input document

Bridge disparate systems EDI Legacy integration

Page 16: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

SOAP: Simple Object Access Protocol Developed by IBM, Microsoft, Lotus,

DevelopMentor, and UserLand Software Lightweight protocol for exchanging

information in a decentralized distributed environment

XML description of an RPC call Implementation could be RMI or ActiveX or

something else Represents an alternative to IIOP Uses HTTP to transport request/response

Page 17: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Document Structure <Envelope> (mandatory)

[Describes SOAP message type] <Header> (optional): Includes

processing instructions for the request <Body> (mandatory): Describes the

parameters

Fault: Includes error codes

Page 18: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

SOAP Example RequestHOST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset=“utf-8”Content-Length: nnnnSOAPAction: “Some-URI”

<SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m=“Some-URI”> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 19: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

SOAP Example ResponseHTTP/1.1 200 OK

Content-Type: text/xml; charset=“utf-8”

Content-Length: nnnn

<SOAP-ENV:Envelope

xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/

SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/>

<SOAP-ENV:Body>

<m:GetLastTradePriceResponse xmlns:m=“Some-URI”>

<price>34.5</price>

</m:GetLastTradePriceResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

Page 20: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Another SOAP Example…<SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/> <SOAP-ENV:Header> <t:Transaction xmlns:t=“some-URI” SOAP-ENV:mustUnderstand=“1”> 5 </t:Transaction> </SOAP-ENV:Header> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m=“Some-URI”> <ticker>IBM</ticker> <showVolume>Yes</showVolume> </m:GetLastTradePrice> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 21: XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000

Copyright © 2000, Sandeep Singhal

Some Other Capabilities Encoding

Can define structures, arrays, enumerations, and other basic data types

Transmission Use standard HTTP 1.1 Use HTTP Extension Framework