XML and PHP [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

XML and PHP [Electronic resources] - نسخه متنی

Vikram Vaswani

نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
تنظیمات قلم


اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
لیست موضوعات
افزودن یادداشت
افزودن یادداشت جدید


Invented by Allaire Corp. (makers of the HomeSite HTML editor and the ColdFusion application development environment), WDDX is ". . . an XML-based technology that enables the exchange of complex data between web programming languages . . ."[1] It was created in 1998 as an open standard designed specifically to simplify data exchange across different platforms, and it has quickly gained popularity with web developers for its elegance and ease of use.

[1] OpenWDDX.org: The Web Distributed Data Exchange. "Web Distributed Data Exchange FAQ." Available from the Internet: http://www.openwddx.org/faq/

WDDX works by converting language-specific data structures into their corresponding XML representations. These XML data structures are text-based, platform-independent entities, and, as such, can be transmitted between different systems over standard HTTP protocols with minimal difficulty. Any WDDX-friendly application can read these WDDX packets, and convert them back into their original form. For example, a Python list could be encoded into WDDX and transmitted across HTTP to a PHP script, which could decode it into a PHP array. Or a PHP associative array could be translated into WDDX, sent to a Perl script, and decoded into a Perl-compliant hash, for use within a Perl script.

Perhaps an example would make this clearer. Consider Listing 5.1, a single-line PHP script that defines a variable and assigns it a value.

Listing 5.1 A Simple PHP Variable

$str = "amoeba"; 

If this variable were to be converted (or, as the geeks say, "serialized" or "pickled") into its WDDX representation, it would look something like Listing 5.2.

Listing 5.2 A WDDX Representation of a PHP Variable

<wddxPacket version='1.0'> 

As you can see, this is regular XML markup, with both the variable type and its value embedded within it. The document element here is the <wddxPacket> element; it can be separated into distinct header and data areas. The header contains a human-readable comment, whereas the data block contains an XML-encoded structure representing the data to be transmitted.

This WDDX representation can be decoded (or "deserialized" or "unpickled") and used by any application that understands WDDX. And so, by creating a standard framework for representing common data structures and by expressing this framework in XML, WDDX makes it possible to easily exchange information over the standard Internet backbone.

WDDX consists of two parts: the WDDX specification that defines basic WDDX structures, and a set of WDDX components for different languages that handles the translation of language-specific data structures into platform-independent XML representations. As of this writing, the WDDX specification supports most commonly used data structures (see the "Not My Type" sidebar for a list), and WDDX components are available for PHP, Perl, ASP, Java, Python, JavaScript, and COM. This immediately makes the technology attractive to developers whose work involves exchanging bits and bytes in multiplatform environments.

It's important to note that WDDX is not an "official" specification per se; rather, it's an open standard created and supported by one company. Despite this, it's fairly popular, primarily for use in client-server or server-server content publishing systems, or as a wrapper for data exchange between multiple programming languages. By allowing applications written in different languages to easily communicate with each other, it also opens the door to new B2B applications, particularly in the areas of streamlining business processes and transactions.

For more information on WDDX, you should refer to the official web site at http://www.openwddx.org/, which contains the WDDX Document Type Definition (DTD), an SDK (if you need to implement WDDX on an unsupported platform), and usage examples.

Not My Type

The WDDX specification currently defines the following data types:

Boolean values, represented by the <boolean> element

Numbers, represented by the <number> element

Strings, represented by the <string> element

Date/time values, encoded in ISO8601 format, represented by the <dateTime> element

Integer-indexed arrays, represented by the <array> element

Structures, or string-indexed arrays, represented by the <struct> element;

Recordsets, or two-dimensional (rows versus columns) data collections, represented by the <recordset> element

/ 84