Hi,
I have a problem:
II use JAXP /Crimson to parse an InputStream with SAXParser.
It does not work. I receive the following error message:
org.xml.sax.SAXParseException: org.apache.crimson.parser/P-001 2d
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3035)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3029)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:505)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:304)
at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
at
org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:1
79)
at examples.TransformationApp02.main(TransformationApp02.java:63)
at examples.HttpConnection.run(HttpConnection.java:77)
If I parse the same XML as a file, it works perfectly. Seems like the parser
never gets the EOF of the stream... The stream is read from a socket, I
build a listener that listens on port 8080 ( http POST upload of an
XML -File).
I need to be able to parse the InputStream ! I don't know what I do wrong ?
Can anyone help ?
Thanks
Susy
public class TransformationApp02
{
// Global value so it can be ref'd by the tree-adapter
static Document document;
public static void main(String [] params) {
try {
//new TransformationApp02().main(new DataInputStream(System.in));
new TransformationApp02().main(new DataInputStream(new
ServerSocket(80).accept().getInputStream()));
} catch (Throwable t) {t.printStackTrace();}
}
public void main (DataInputStream xml)
//public void main (DataInputStream xml)
{
//if (argv.length != 1) {
// System.err.println ("Usage: java TransformationApp filename");
// System.exit (1);
//}
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
//factory.setNamespaceAware(true);
//factory.setValidating(true);
try {
File f = new File("g:/Java/a.xml");
//xml = new DataInputStream(new FileInputStream(f));
//xml = new DataInputStream(System.in);
//new DumpSocket(xml);
DocumentBuilder builder = factory.newDocumentBuilder();
System.out.println("**---------------------------------");
if (f != null){
//BufferedReader br = new BufferedReader(xml);
//InputSource inputSource = new InputSource(br);
document = builder.parse(new InputSource(xml));
System.out.println("*--parsing xml");
System.out.println(document.getDocumentElement());
//while (f != null)
//System.out.println(xml.readLine());
}
// Use a Transformer for output
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
----------------------------------------------------------------------------
-------------------------
Susy Pfeiffer Email: [EMAIL PROTECTED]
Development Mobile
Critical Path GmbH WWW: http://www.cp.net
Katharinenstr. 17-18 Tel: +49.30/89 66 0-0
D-10711 Berlin, Germany Fax: +49.30/89 66 0-999
----------------------------------------------------------------------------
-------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]