WDDX: Web Distributed Data Exchange, or WDDX, is a free, open XML-based technology that allows Web applications created with any platform to easily exchange data with one another over the Web. For more info, See http://www.openwddx.org/ . Are there any WDDX-parsers for TCL? ---- Example packet #1:
This is WDDX packet example Example packet #2:
3.1415926 Austin Novato Seattle ---- [LV] Based on this example,WDDX appears to be a specific application of [XML]. There are a couple of XML extensions for Tcl - [tdom] and [tclxml] at the very least. I'm uncertain what one would need to use with either of these to be considered a ''WDDX'' parser. ---- [schlenk] 2005-10-06 Based on the description of WDDX it seems like a serialization protocol for application data. As Tcl does not really have most of the types of for example Java or C one would have to create a mapping from WDDX to Tcl Data structures, probably something like [struct]::[record] or one of the OO packages. With [tdom] and some XPath expression it should be quite straightforward to do once you decide on a mapping. Based on a short look at the wddx dtd from the openwddx link above, i can say doing WDDX with Tcl will be quite straight forward. I must also say it doesn't look like the best specification, the authors seem to not understand XML whitespace handling correctly. [NEM] is slightly confused about that bit. Surely the length is easily available by just counting the number of children nodes, which should be trivial with any XML parser. And what if the length specified and the number of child nodes differ? Too much C-coding leaking into the spec? [schlenk] has a similar impression from reading the DTD, lots of C style restrictions (like not trusting the whitespace preservation of xml:space="preserve" attributes, disallowing NULL bytes in strings (although they are allowed in utf-8), forcing users to encode escape characters in strings with their Unicode codepoints although XML has UTF-8 as native encoding and can do so without those clumsy hacks.). ---- package require tdom set wddxpacket {
3.1415926 Austin Novato Seattle }; proc getWDDXrootDOM {wddxPacket} { set doc [dom parse $wddxPacket]; set root [$doc documentElement]; return $root; } proc getWDDXdata {wddxPacket path} { set root [getWDDXrootDOM $wddxPacket]; return [$root selectNodes $path]; } set versionPath {string(@version)}; set packetVersion [getWDDXdata $wddxpacket $versionPath]; puts "Version is $packetVersion"; set headerCommentPath {string(header/@comment)}; set headerComment [getWDDXdata $wddxpacket $headerCommentPath]; puts "Comment is $headerComment"; set citiesCountPath {string(data/struct/var[@name='cities']/array/@length)}; set citiesCount [getWDDXdata $wddxpacket $citiesCountPath]; puts "number of cities is $citiesCount"; for {set i 0} {$i < $citiesCount} {incr i} { set cityPath "string(data/struct/var\[@name='cities'\]/array/string\[[expr $i + 1]\])"; set city [getWDDXdata $wddxpacket $cityPath]; puts "city #$i is $city"; } Output: Version is 1.0 Comment is Another example number of cities is 3 city #0 is Austin city #1 is Novato city #2 is Seattle ---- [Category Glossary] [Category Internet]