Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Having a really bad time, and I fear it's all line endings

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Andrew Thompson <lordpixel AT mac.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Having a really bad time, and I fear it's all line endings
  • Date: Sun, 06 Mar 2005 15:12:49 -0500

Andrew Thompson wrote:


InputStream fis = new FileInputStream(a_inputFile);
Reader r = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
Document unresolved = new Builder().build(r);

Because you've built from a Reader rather than a File, there's no base URI. Hence relative URIs cannot be resolved. To fix it you need to do:

unresolved.setBaseURI("file:///whatever/");

This should probably be a FAQ. And you're right, the error message could perhaps be more helpful. I'll see if I can improve that. The question is whether I can easily distinguish this case (no base URI) from the case of a malformed base URI. I probably can, but I'm not sure yet.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page