Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1084

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
<!--- Query the database and get the names in the employee table --->
<cfquery name="myQuery" datasource="cfdocexamples">
SELECT FirstName, LastName
FROM employee
</cfquery>
<!--- Create an XML document object containing the data --->
<cfxml variable="mydoc">
<employee>
<cfoutput query="myQuery">
<name>
<first>#FirstName#</first>
<last>#LastName#</last>
</name>
</cfoutput>
</employee>
</cfxml>
<!--- dump the resulting XML document object --->
<cfdump var=#mydoc#>
<!--- Write the XML to a file --->
\\x
output=#toString(mydoc)#>
Validating XML documents
ColdFusion provides the following methods for validating a document against a DTD or an XML Schema:
• The
function can validate XML text that it is parsing against a DTD or Schema. It the function
XmlParse
encounters a validation error, ColdFusion generates an error and stops parsing the text. If the validator generates
warnings, but no errors, ColdFusion parses the document and returns the result.
• The
function can validate an XML text document or XML document object. against a DTD or
XmlValidate
Schema. The function returns a data structure with detailed information from the validator, including arrays of
warning, error, and fatal error messages, and a Boolean status variable indicating whether the document is valid.
Your application can examine the status information and determine how to handle it further.
For examples of XML validation, see
validates a document using a DTD. The
represents the same document structure as the DTD.
Transforming documents with XSLT
The Extensible Stylesheet Language Transformation (XSLT) technology transforms an XML document into another
format or representation. For example, one common use of XSLT is to convert XML documents into HTML for
display in a browser. XSLT has many other uses, including converting XML data to another format, such as converting
XML in a vocabulary used by an order entry application into a vocabulary used by an order fulfillment application.
XSLT transforms an XML document by applying an Extensible Stylesheet Language (XSL) style sheet. (When stored
in a file, XSL style sheets typically have the .xsl extension.) ColdFusion provides the
an XSL transformation to an XML document. The function takes an XML document in string format or as an XML
document object, and an XSL style sheet in string format, and returns the transformed document as a string.
The following code:
1
Reads the simpletransform.xsl style sheet file into a string variable.
and
XmlParse
XmlValidate
example validates the document using an XML Schema that
XmlValidate
Last updated 1/20/2012
in the CFML Reference. The
XmlTransform
1079
example
XmlParse
function to apply

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents