[jdom-interest] XML through socket and URI problem

Flávio Marim flavio at bs2.com.br
Mon Aug 30 11:21:09 PDT 2004


I'm writing an app that receives from a socket connection a XML file.

I do

InputStream socketThing = socket.getInputStream();

and call a method with socketThing as argument as follows:

//(1)
public static Document buildReader(InputStream socketThing) {
   InputStreamReader input = new InputStreamReader(socketThing);
   BufferedReader in = new BufferedReader(input);

   try {
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(in);
   }catch{
      //(...)
   }

The app says that:

org.jdom.input.JDOMParseException: Error on line 2: Relative URI
"dtdFile.dtd"; can not be resolved without a base URI.

I tried using

//(2)
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getSystemResource("xmlFile.xml");
Document doc = builder.build(url);

Like suggested in forum archives and it worked fine.
The problem is that I'll never have a stored xml file. It comes from a
socket connection so I can't use the (2) method.

Any suggestion?

Thanks in advance.


-- 
Flávio Marim
Benner Technology and Health Systems LTD.
Maringa - Parana - Brazil


More information about the jdom-interest mailing list