/*
 * MIDBench.java
 *
 * Created on February 26, 2003, 4:07 PM
 */

package MIDBench;

import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import nanoxml.*;

/**
 *
 * @author  Administrator
 * @version
 */
public class MIDBenchNanoXMLsoap extends javax.microedition.midlet.MIDlet {

    private static void testNanoXML(String s) throws IOException {
        ByteArrayInputStream bin = 
            new ByteArrayInputStream(s.getBytes());
        kXMLElement root = new kXMLElement();
        root.parseFromReader(new InputStreamReader(bin));
    }
    
    private Form form;
    public void startApp() {
        String output = "Parsing done!";
        try {
            for (int i = 0; i < 5; i++ ) {
                testNanoXML("<SOAP-ENV:Envelope\n" +
                          "  xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
                          "  SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" +
                          "   <SOAP-ENV:Header>\n" +
                          "       <t:Transaction\n" +
                          "         xmlns:t=\"some-URI\"\n" +
                          "         xsi:type=\"xsd:int\" mustUnderstand=\"1\">\n" +
                          "           5\n" +
                          "       </t:Transaction>\n" +
                          "   </SOAP-ENV:Header>\n" +
                          "   <SOAP-ENV:Body>\n" +
                          "       <m:GetLastTradePriceResponse\n" +
                          "         xmlns:m=\"Some-URI\">\n" +
                          "           <Price>34.5</Price>\n" +
                          "       </m:GetLastTradePriceResponse>\n" +
                          "   </SOAP-ENV:Body>\n" +
                          "</SOAP-ENV:Envelope>\n");        
            }
        } catch (Exception e) {
            output = "Parsing failed!";
        }
        form = new Form("Done");
        form.append(new StringItem(null, output));
        Display.getDisplay(this).setCurrent(form);
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
}
