Moving Complex Data Across The Web With Wddx - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Code
<cfquery name="priceQuery" dbType="query">
SELECT SUM(qty*unitPrice)
AS totalPrice
FROM orderquery
</cfquery>
<cfset discountPrice = priceQuery.totalPrice
* (1 - drate/100)>
<cfxml variable="receiptxml">
<receipt num = "34">
<cfoutput>
<price>#discountPrice#</price>
<cfif drate GT 0 >
<discountRate>#drate#</discountRate>
</cfif>
</cfoutput>
<itemsFilled>
<cfoutput query="orderQuery">
<name>#name# </name>
<qty>
#qty#
<price>
#qty*unitPrice#
</cfoutput>
</itemsFilled>
</receipt>
</cfxml>

Moving complex data across the web with WDDX

WDDX is an XML vocabulary for describing a complex data structure, such as an array,
associative array (such as a ColdFusion structure), or a recordset, in a generic fashion. It lets you
use HTTP to move the data between different application server platforms and between
application servers and browsers. Target platforms for WDDX include ColdFusion, Active Server
Pages (ASP), JavaScript, Perl, Java, Python, COM, Macromedia Flash, and PHP.
The WDDX XML vocabulary consists of a document type definition (DTD) that describes the
structure of standard data types and a set of components for each of the target platforms to do the
following:
Serialize
the data from its native representation into a WDDX XML document or
document fragment.
Deserialize
representation, such as a CFML structure.
This vocabulary creates a way to move data, its associated data types, and descriptors that allow
the data to be manipulated on a target system, between arbitrary application servers.
Note: The WDDX DTD, which includes documentation, is located at
www.openwddx.org/downloads/dtd/wddx_dtd_10.txt.
While WDDX is a valuable tool for ColdFusion developers, its usefulness is not limited to
CFML. If you serialize a common programming data structure (such as an array, recordset, or
structure) into WDDX format, you can use HTTP to transfer the data across a range of languages
and platforms. Also, you can use WDDX to store complex data in a database, file, or even a client
variable.
</qty>
</price>
a WDDX XML document or document fragment into the native data
Description
Uses a query of queries with the SUM
operator to calculate the total cost before
discount of the ordered items, then applies the
discount to the price. The result of the query is
a single value, the total price.
Creates an XML document object as a
receipt. The receipt has a root element named
receipt, which has the receipt number as an
attribute. The receipt element contains a price
element with the order cost and an itemsFilled
element with one item element for each item.

Moving complex data across the web with WDDX

697

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents