Problem with using InputSource in SAXParser
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   f4xterminator_t800xxx2003
Posted On:   Wednesday, October 29, 2003 09:31 PM

need urgent help... the xml (xhtml) that i need to parse using (xerces) SAXParser comes from a MIDlet, the data is passed (in xhtml format) to a servlet which then calls the parser to parse the data. Unfortunately, J2ME doesn't have file handling classes/methods thus the need of my parser to use InputSource. the MIDlet (client) is sending the data in xhtml format, and then the parser should parse the data directly from the InputStream. when the MIDlet tries to send data, the parser is getting an unknown source... some code snippets: //(inside my servlet) ServletInputStream in = request.getInputStream(); DataInputStream din = new DataInputStream(in); TempXMLParser myParser    More>>

need urgent help...

the xml (xhtml) that i need to parse using (xerces) SAXParser comes from a MIDlet, the data is passed (in xhtml format) to a servlet which then calls the parser to parse the data. Unfortunately, J2ME doesn't have file handling classes/methods thus the need of my parser to use InputSource. the MIDlet (client) is sending the data in xhtml format, and then the parser should parse the data directly from the InputStream. when the MIDlet tries to send data, the parser is getting an unknown source...


some code snippets:

			

//(inside my servlet)
ServletInputStream in = request.getInputStream();
DataInputStream din = new DataInputStream(in);
TempXMLParser myParser = new TempXMLParser(din);
Vector data = myParser.getData(); // see parser class


//(inside my SAX parser)

Vector list = new Vector();
InputSource source;


// constructor
public TempXMLParser (InputStream stream) {


source = new InputSource(stream);
source.setEncoding("UTF-8");

}

			

public Vector getData() throws SAXException,IOException{

// create a Xerces SAX parser
SAXParser parser = new SAXParser();

// set the content handler
parser.setContentHandler(this);

// parse the document
try{
parser.parse(source);

}
catch (SAXException e) {
System.err.println (e);
throw e;
}
catch (IOException e) {
System.err.println (e);
throw e;
}
return list;
}




i couldn't pinpoint where the error might be... please help. thanks. :)

   <<Less
About | Sitemap | Contact