1 / 31

XML – Its Role and Use

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. The Problem. An Example. Organization A works with a supplier (organization B)

keithgrimes
Download Presentation

XML – Its Role and Use

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Agenda • The Problem • Introducing XML • Working with XML • ColdFusion MX and XML • Web Services

  3. The Problem

  4. An Example • Organization A works with a supplier (organization B) • Organization A does not have access to organization B's IT systems

  5. The Problem • All interaction between the two organizations is manual • Order submission • Status checking • Payment • Reporting

  6. The Need • The two organizations need to share information, despite differing environments and incompatible applications

  7. Introducing XML

  8. What XML Is Not • XML is not a way to format page layout (as is HTML) • XML is not a presentation language

  9. What Is XML • XML is less a “language” per se, and more a way to describe data • XML data is described using “vocabularies”

  10. 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

  11. 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

  12. 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

  13. 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>

  14. Working With XML

  15. 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

  16. 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

  17. 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

  18. 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)

  19. ColdFusion MX and XML

  20. ColdFusion MX and XML • ColdFusion provides build in support for: • Reading XML data • Writing XML content • Applying XSL transformation • Performing XPath searches

  21. 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()

  22. 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>

  23. 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>

  24. Applying XSL Transformations • XSL transformation are applied using XMLTransform() • <CFOUTPUT>#XMLTransform(xmlfeed, xsldoc)#</CFOUTPUT>

  25. 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)>

  26. Web Services

  27. 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

  28. 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>

  29. Publishing Web Services • Any ColdFusion components can be made accessible as a Web service by simply defining the ACCESS in the component methodACCESS="remote" • ColdFusion Components and methods may be secured using: • User roles • Access levels

  30. Summary • XML is data sharing • ColdFusion MX makes XML usable • Web Services facilitate distributed XML data sharing

  31. Q&A

More Related