Date: 2004-07-21T06:32:21 Editor: AlexanderBeening <[EMAIL PROTECTED]> Wiki: Cocoon Wiki Page: Midlets URL: http://wiki.apache.org/cocoon/Midlets
no comment Change Log: ------------------------------------------------------------------------------ @@ -1,19 +1,23 @@ +Results from a Cocoon pipeline (out of an XML serializer) can also be used to answer a Midlet at a mobile phone (using MIDP/CLDC with the Java 2 Micro Edition or J2ME platform). To do this. the Midlet has to be able to parse the incoming XML, received as a byte array. This message explains the principle to do this. + +First problem: How to parse XML in J2ME? There is a solution: To parse XML in J2ME, use kXML. It works really well! (see: [http://kxml.objectweb.org/software/downloads/] to obtain the package and the docs) == How it works == -On the server side: +On the server side (Cocoon 2/ Tomcat 4): - 1. In a pipeline: Action to lookup the data (EJB - J2EE to JBoss) and pass the object of interest to the request with request.setAttribute(<name>, <object>) - 1. Generate xsp, using a logicsheet which creates XML from the object - 1. Serialize (so skip Transform!) to XML. + Create a pipeline: + 1. Action to lookup the data (class, implementing the Action-interface and instatiating an EJB - J2EE to JBoss) and pass the object of interest (delivered by the EJB) to the request with request.setAttribute(<name>, <object>) + 2. Generate xsp, using a logicsheet which creates XML from the object + 3. Serialize (so skip Transform!) to XML. -On the mobile phone: +On the mobile phone in the Midlet: 1. Open a HttpConnection for the URL for which the pipeline-match is valid (will execute the pipeline, mentioned above) - 1. Create a DataInputStream, using the HttpConnection object from Step 1 - 1. Read the XML, produced by the server , using a read-method of the DataInputStream object in a byte-array - 1. Create a parser object, using the byte-array. + 2. Create a DataInputStream, using the HttpConnection object from Step 1 + 3. Read the XML, produced by the server , using a read-method of the DataInputStream object in a byte-array + 4. Create a parser object, using the byte-array. Putting it all together, in the Midlet, you should create a method like this:
