[xmlrpcflash-development] Patrick's patch code for the response parse bug
Brought to you by:
dopelogik
From: Isaac L. <ik...@vi...> - 2002-11-05 22:48:04
|
Just thought I'd post this code here, for the record- It is a Patch for the 0.5 Alpha release: > On Tuesday, October 8, 2002, at 09:32 PM, Patrick O'Lone wrote: > >> >> Actually, the unreleased API simply abstracts more from the >> implementor by >> auto-calling most methods implicitly. In addition, some clarification >> of the >> types created and bug fixes were implemented. But now that I've heard >> more >> about your woes with the engine's getResults() method, I'm wondering >> if the >> best solution is to simply force the developer to implement callbacks. >> The >> idea would be something like this: >> >> EchoClient.prototype.__proto__ = XMLRPC.prototype; >> EchoClient.prototype.startElement() = function ( name, attrs ) { >> >> // Handle structs how I see fit >> >> } >> >> EchoClient.prototype.endElement() = function ( name ) { >> >> // Handle array elements how I see fit >> >> } >> >> EchoClient.prototype.dataElement() = function ( data ) { >> >> // Deal with data elements >> >> } >> >> objEchoClient = new EchoClient(); >> >> Perhaps, the XMLRPC object would simply call these methods of itself, >> with >> the assumption the developer is to implement these by inheriting the >> XMLRPC >> class and defining these methods, then instantiate that object to >> process >> the XML-RPC message. The object would still call getResults(), but the >> method would now run parse() and call the subclass's overloaded >> methods >> instead (we'd set defaults for debug purposes). >> A sample rework of Parse() (it's MUCH simpler IMHO) would be: function Parse ( Node ) { if (Node.nodeType == 3) { // Data elements call the dataElement() method as overloaded // by the inherited class. this.dataElement(Node.nodeValue); } else if (Node.nodeType == 1) { // Tag elements call startElement() first, and pass any attributes // that exist to that method as well. this.startElement(Node.nodeName, Node.attributes); for (var i in Node.childNodes) { // Parse each child node that this node has. this.Parse(Node.childNodes[i]); } // End this element by calling the overloaded endElement() method this.endElement(Node.nodeName); } else { // Something has gone terribly wrong - this isn't // a possible state! return false; } return true; } Regards, ----------------------------------------- Patrick O'Lone Aeon Solutions, Inc. |