Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] XML through socket and URI problem

Flávio Marim

2004-08-30

Replies:

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
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.