From: Marcus W. <ma...@ph...> - 2005-01-06 22:06:48
|
Hey, So, I'm trying to think about what is wrong with the idea of standardizing on storing and returning data as UTF-8, and making Modules the common public API of all applications, and I can't figure that out. UTF-8 is the XML character set of choice, which means this is the highest level of interoperability we could achieve. It's anal to insist on it, but... I believe it's a step in the right direction. It puts us in a better place for data transformation and I18n. Also, it's a great way to separate business logic and display logic. For example, it would be sweet if I could access the same module like so: From a Web Browser: http://example.com/web_transport/view:MyView/state:MyState/param1:MyParam1 From a REST Web Service: http://example.com/rest_transport.php?view=MyView&state=MyState¶m1=MyParam1 FROM a SOAP Client: | <?php $client = new SoapClient(NULL, array( "location" => "http://example.com/soap_transport", "uri" => "urn:cep-view", "style" => SOAP_RPC, "use" => SOAP_ENCODED )); print($client->__call( /* SOAP Method Name */ "MyView", /* Parameters */ array( new SoapParam( /* Parameter Value */ "MyState", /* Parameter Name */ "state" ), || new SoapParam( /* Parameter Value */ "MyParam1", /* Parameter Name */ "param1" )||), /* Options */ array( /* SOAP Method Namespace */ "uri" => "urn:xmethods-delayed-quotes", /* SOAPAction HTTP Header for SOAP Method */ "soapaction" => "urn:cep-view#MyView" )). "\n"); ?> | of course a WSDL would simplify the above SOAP call. FROM the Command Line: cli_transport --view=MyView --state=MyState --param1=MyParam1 Then we could each module essentially do the same thing, except transform the XML according to the transport used. Where that logic should be, I'm not certain, but I don't just want component reusablity, I want API abstraction as well. XSL is performs pretty damn well in PHP5 in my tests so far. I think it really could do the job of making the XML into an appropriate output format. What I would love to see is a PHP Class that gave me an IT like interface to create XSLT tags. That would be nice. I wonder if modules (or pages or components or what the hell ever!!!) should have render methods for the various transports. So if one isn't present, the basic XML is returned, however if one exists it is used to transform the XML. I think I'm going to play with this idea in a module and see how I like it... thoughts, insight, rants, counter-points are very welcomed. |