Adobe 38000827 Evaluator Guide - Page 20

XML Handling

Page 20 highlights

Macromedia® ColdFusion® MX Evaluator's Guide XML Handling The Extensible Markup Language (XML) is becoming a widely adopted technology for sharing data between different operating platforms, applications, devices, and systems. Traditional methods for transferring data between disparate machines such as the use of comma-delimited files or other ad-hoc protocols are limited because of lack of standards and the inability to represent complex data types and describe relationships. XML addresses this problem by providing developers with a single text-based markup language that can describe both documents and data as well as represent both simple and complex data relationships. Until now, using XML in most web development languages has been a tedious process, requiring in-depth knowledge of XML parsers and how to interact with their complex programming interfaces and object models. ColdFusion MX introduces a revolutionary approach to XML by allowing developers to parse, create, and manipulate XML documents using the same easy to use scripting syntax used in CFML. As a result, developers can easily incorporate XML data into their applications without the overhead of having to deal with complex, low-level programming constructs. Parsing and Creating XML Data The built-in XML parser that is now part of ColdFusion MX automatically processes XML that is passed to ColdFusion and converts it into a native ColdFusion object, making it easy for developers to manipulate incoming XML data in their applications. The XML object is a structure of CFML structs and arrays, which means that developers navigate XML the object using the same syntax ColdFusion provides for reading and writing other complex data types. ColdFusion MX also makes it easy for developers to generate XML as output in their applications. The creation of XML documents usually requires an understanding of the Document Object Model (DOM) and its associated API. Developers must execute multiple function calls to create nodes, set their values, and then serialize the object to generate an XML string. By contrast, ColdFusion MX provides a single tag that automatically generates a valid XML document from text, application variables, and the output of CFML code embedded within its body. As a result, developers can quickly and easily exchange data with other applications using standards-based XML. Manipulating XML Data The XML specification also provides two powerful methods for manipulating data that is stored in XML. These include XSLT style sheets and XPath searches. Style sheets enable developers to convert XML data from one format to another. For example, if a developer is merging employee data represented in two different XML schemas, he or she can use a transformation to convert the two sets of data so that they share the same schema. XPath provides a different way to navigate through XML data. XPath searches are similar to SQL queries in that they enable an application to search for a specific set of data contained in an XML document (as opposed to accessing a particular known location in the XML document). The ColdFusion MX scripting environment provides native support for both of these powerful technologies, making it easy for developers to work with XML data. With the new XMLTransform function, a developer simply needs to pass in an XML document and the appropriate XSLT style sheet, and ColdFusion MX performs the transformation. Similarly, XPath searches are enabled through the easy to use XMLSearch function. 20

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

Macromediafi ColdFusionfi MX Evaluator°s Guide
XML Handling
The Extensible Markup Language (XML) is becoming a widely adopted technology for
sharing data between different operating platforms, applications, devices, and systems.
Traditional methods for transferring data between disparate machines such as the use of
comma-delimited files or other ad-hoc protocols are limited because of lack of standards
and the inability to represent complex data types and describe relationships. XML
addresses this problem by providing developers with a single text-based markup
language that can describe both documents and data as well as represent both simple
and complex data relationships.
Until now, using XML in most web development languages has been a tedious process,
requiring in-depth knowledge of XML parsers and how to interact with their complex
programming interfaces and object models. ColdFusion MX introduces a revolutionary
approach to XML by allowing developers to parse, create, and manipulate XML
documents using the same easy to use scripting syntax used in CFML. As a result,
developers can easily incorporate XML data into their applications without the overhead
of having to deal with complex, low-level programming constructs.
Parsing and Creating XML Data
The built-in XML parser that is now part of ColdFusion MX automatically processes XML
that is passed to ColdFusion and converts it into a native ColdFusion object, making it
easy for developers to manipulate incoming XML data in their applications. The XML
object is a structure of CFML structs and arrays, which means that developers navigate
XML the object using the same syntax ColdFusion provides for reading and writing other
complex data types.
ColdFusion MX also makes it easy for developers to generate XML as output in their
applications. The creation of XML documents usually requires an understanding of the
Document Object Model (DOM) and its associated API. Developers must execute
multiple function calls to create nodes, set their values, and then serialize the object to
generate an XML string. By contrast, ColdFusion MX provides a single tag that
automatically generates a valid XML document from text, application variables, and the
output of CFML code embedded within its body. As a result, developers can quickly and
easily exchange data with other applications using standards-based XML.
Manipulating XML Data
The XML specification also provides two powerful methods for manipulating data that is
stored in XML. These include XSLT style sheets and XPath searches. Style sheets enable
developers to convert XML data from one format to another. For example, if a developer
is merging employee data represented in two different XML schemas, he or she can use a
transformation to convert the two sets of data so that they share the same schema.
XPath provides a different way to navigate through XML data. XPath searches are similar
to SQL queries in that they enable an application to search for a specific set of data
contained in an XML document (as opposed to accessing a particular known location in
the XML document).
The ColdFusion MX scripting environment provides native support for both of these
powerful technologies, making it easy for developers to work with XML data. With the
new XMLTransform function, a developer simply needs to pass in an XML document and
the appropriate XSLT style sheet, and ColdFusion MX performs the transformation.
Similarly, XPath searches are enabled through the easy to use XMLSearch function.
20