ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

16
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward

Transcript of ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Page 1: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

ColdFusion’s XML Capabilities

Maryland CFUG

April 12, 2005

Presented by Doug Ward

Page 2: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Agenda

What is XML? Creating XML Parsing XML Searching XML Transforming XML XML examples

Page 3: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Sources

Programming ColdFusion MX, 2nd Edition, by Rob Brooks-Bilson

Utilizing XML and XSLT in ColdFusion MX, Nate Weiss

On Using XML Well: Creating a dynamic XML menu, by Ben Forta

Page 4: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

A Definition of XML

“XML is a tag-based markup language for describing data”

What is XML?

Page 5: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

How XML is similar to HTML

XML and HTML are both subsets of SGML (Standards Generalized Markup Language)

XML and HTML are both plain-text formats utilizing tags (called elements in XML) and attributes

What is XML?

Page 6: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

How XML is different from HTML

XML demands strict adherence to correct syntax

XML doesn’t have anything to do with how the data it describes is displayed

XML is extensible

What is XML?

Page 7: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Creating an XML Document

The XML declaration XML comments The root element Nested child elements Element attributes

Creating XML

Page 8: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Generating XML in ColdFusion

Generating XML using the <CFXML> tag Using the XmlFormat() tag to sanitize strings

Creating XML

Page 9: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

The XML Document Object

The XML document object is a ColdFusion MX datatype

The XML document object shares many similarities with ColdFusion structures and arrays

The XmlParse() function

Parsing XML

Page 10: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Referencing an XML Document Object

Basic view DOM (Document Object Model) node view

Parsing XML

Page 11: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Basic View

Top-level document object and the root structure

Element structures Using structure and array functions to access

elements of the XML document object

Parsing XML

Page 12: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

DOM Node View

In the DOM node view, XML documents are represented as a hierarchical tree of nodes

Each node in the tree consists of a node name, a node type, and a node value

Parsing XML

Page 13: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Matching XML Data with XPath

XPath is a W3C recommendation outlining a language for addressing parts of an XML document

ColdFusion supports XPath as a query tool for extracting data from XML document objects via the XmlSearch() function

Searching XML

Page 14: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

Transforming XML with XSLT

XSLT (Extensible Stylesheet Language Transformation) works with XSL (Extensible Stylesheet Language) to perform the actual transformations

ColdFusion MX uses the XMLTransform() function to perform an XSLT transformation on an XML string or document object

Transforming XML

Page 15: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

XML Examples

Dynamic XML menus WDDX data files

Page 16: ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.

XML Resources

www.xml.com www.oasis-open.org XML and XSLT in ColdFusion MX On using XML well