|
|
WDDX: A Deeper Lookby Nate Zelnick A Quick ExampleSay you wanted to represent the output of a simple form on a page that collected user information--first name, last name, and birthdate, for instance--the kind of information that is likely to be useful across a whole range of applications. This would be represented in a WDDX "packet". WDDX structures are called packets because the XML representation of the data is only important (generally) as an entity on the wire in the space between apps. This data would consist of two strings and a date in all languages (or at least all languages that support the concept of a date type). Each variant consists of a name-value pair. This name-value pair relationship is what gives the packet its structure. Representing an instance of this data might look like this: <wddxPacket version="0.9"> <header> </header> <data> <var name="firstname"> <string>Joseph </var> <var name="lastname"> <string>Josephson </var> <var name="birthdate" <datetime>12/12/67 </var> </data> </wddxPacket> This doesn't appear to be all that exciting. After all, this kind of flat data is not that rich or complex, and the data itself has next to no inter-relationships. But what if you wanted to deliver a bunch of different people's information and maintain the relationship between all of those firstnames, lastnames and birthdates? To do this, you need to take the flat data of a single person's data and create a structure that packs multiple records into an array, such that all of the relationships remain intact. Not a particularly hard computer science problem, but tough to do across different languages and platforms on the Web. To do this you enclose the data in structures:
...{heading info clipped for brevity}
<data>
<struct>
<var name="friends">
<array length=2>
<array length=3>
<string>Joseph
<string>Josephson
<datetime>12/12/67
</array>
<array length=3>
<string>Ben
<string>Benson
<datetime>11/11/27
</array>
</array>
</var>
</struct>
</data>
This creates a two-dimensional array with three fields that can be used across all of the different platforms above--as long as they support the serializer and deserializer objects that turn native structures into WDDX packets a(nd back again) for the target platform. Next column, we'll finish this topic off with some sample applications.
Copyright © 1999-2001 internet.com Corp.All Rights Reserved. Legal Notices. Contact the WebDeveloper.com® staff Last modified: Friday, 22-Aug-2008 13:46:47 EDT |
Refresh Daily
|