xml – its role and use ben forta senior product evangelist, macromedia

31
XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Upload: godfrey-hudson

Post on 14-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

XML – Its Role and Use

Ben FortaSenior Product Evangelist, Macromedia

Page 2: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Agenda

The Problem

Introducing XML

Working with XML

ColdFusion MX and XML

Web Services

Page 3: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

The Problem

Page 4: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

An Example

Organization A works with a supplier (organization B)

Organization A does not have access to organization B's IT systems

Page 5: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

The Problem

All interaction between the two organizations is manual Order submission

Status checking

Payment

Reporting

Page 6: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

The Need

The two organizations need to share information, despite differing environments and incompatible applications

Page 7: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Introducing XML

Page 8: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

What XML Is Not

XML is not a way to format page layout (as is HTML)

XML is not a presentation language

Page 9: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

What Is XML

XML is less a “language” per se, and more a way to describe data

XML data is described using “vocabularies”

Page 10: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Understanding XML

XML serves two primary purposes: Provides a framework to separate data

from presentation and layout

Provides a syntax that allows applications to share data

XML defines common information formats across nearly every major computing endeavor

Page 11: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Example - The Challenge

An organization relies on multiple suppliers, each of whom uses a different computer system and thus a different way to describe parts

The challenge is to retrieve real time status information from multiple sources so as to be able to present it in a consistent format

Page 12: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Example - The Solution

An XML format (a “vocabulary”) is agreed upon ahead of time, by the suppliers

Each supplier publishes data in the agreed upon format

The client retrieves the standardized data as needed

Page 13: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Example - Sample Data

Sample XML vocabulary

<ORDER_STATUS> <SUPPLIER_ID>123</SUPPLIER> <ORDER_NUM>A24680</ORDER_NUM> <STATUS>Shipped</STATUS> <SHIP_DATE>20020101</SHIP_DATE> <SHIP_VIA>UPS</SHIP_DATE> ...</ORDER_STATUS>

Page 14: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Working With XML

Page 15: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

XML Terminology

DTD – data definition document describing the XML data (sometimes called a schema)

DOM – document object model, a hierarchical view of XML content

Node – an item in the DOM, nodes are made up of a type, a name, and a value

Root – top level element in a document

Element – the actual content

Page 16: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Displaying XML Data

XML is NOT a page layout language

XML describes data

XML data can be displayed in any client technology, including HTML, Flash, Java, JavaScript, ActiveX

Page 17: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Working with XML

Working with XML requires tools that can manipulate structured XML data Read values

Walk trees

Search for and extract specific elements

Set values and build trees

Page 18: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Applying Transformations

XSL is a template language that is used to provide display rules for XML data

XML is data, XSL is a set if display rules

XSL is applied to XML generating a transformation (the actual output)

Page 19: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

ColdFusion MX and XML

Page 20: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

ColdFusion MX and XML

ColdFusion provides build in support for: Reading XML data

Writing XML content

Applying XSL transformation

Performing XPath searches

Page 21: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

XML In ColdFusion

Within ColdFusion, XML documents are accessed as objects

An XML object in ColdFusion is a structure, and can be access as such

Objects are created using: <CFXML> XMLNew() XMLParse()

Page 22: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Reading XML Data

XMLParse() converts an xml document into an XML object

<CFFILE ACTION="read" FILE="#xmlfile#" VARIABLE="xmldata"> <CFSET xmlobj=XMLParse(xmldata)><CFOUTPUT> #root.order_status.status#</CFOUTPUT>

Page 23: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Writing XML Content

<CFXML> or XMLNew() creates XML objects that may be populated as needed

<!--- Create XML object ---><CFXML VARIABLE="Orders"> <Orders> <!--- Loop through orders ---> <CFOUTPUT QUERY="orders"> <!--- Write order ---> <order> <ordnum>#ordnum#</ordnum> <status>#status#</status> </order> </CFOUTPUT> </Orders></CFXML>

Page 24: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Applying XSL Transformations

XSL transformation are applied using XMLTransform()

<CFOUTPUT>#XMLTransform(xmlfeed, xsldoc)#</CFOUTPUT>

Page 25: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Performing XPath Searches

XPath is a search language used to find and extract values from an XML document

XPath uses search patterns to specify search criteria

<CFSET result=XMLSearch(xmlfeed, pattern)>

Page 26: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Web Services

Page 27: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Why Web Services?

XML is data and facilitates data sharing

Web Services are distributed applications built on top of XML (and SOAP)

Where XML formats data for sharing, SOAP facilitates that sharing

Page 28: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Access to Web Services

<CFINVOKE> provides access to any Web Services

<CFINVOKE WEBSERVICE="http://www.xmethods.net/sd/2001/BabelFishService.wsdl"METHOD="BabelFish"TRANSLATIONMODE="en_fr"SOURCEDATA="Hello, my name is Ben"RETURNVARIABLE="name_french">

<CFOUTPUT>#name_french#</CFOUTPUT>

Page 29: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Publishing Web Services

Any ColdFusion components can be made accessible as a Web service by simply defining the ACCESS in the component method

ACCESS="remote"

ColdFusion Components and methods may be secured using: User roles

Access levels

Page 30: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Summary

XML is data sharing

ColdFusion MX makes XML usable

Web Services facilitate distributed XML data sharing

Page 31: XML – Its Role and Use Ben Forta Senior Product Evangelist, Macromedia

Q&A