[Biojava-l] JAXP

Thomas Down td2@sanger.ac.uk
Tue, 26 Jun 2001 09:04:44 +0100


On Tue, Jun 26, 2001 at 10:36:11AM +1200, Schreiber, Mark wrote:
> Hi,
> 
> I've been trying to use JAXP for XML parsing with the following snippet of
> code:
> 
> 
>         InputStream is = new FileInputStream(args[0]);
>         InputStreamReader isr = new InputStreamReader(is);
>         char[] data = new char[is.available()];
>         isr.read(data);
>         String xmldata = new String(data);
>         InputSource source = new InputSource(new StringReader(xmldata));
>         //System.out.print(xmldata);
>         saxParser.parse(xmldata, this);

Um...  You seem to be constructing an InputSource (the normal
way to invoke SAX-ish parsers, then calling the 
parse(String, DefaultHandler) method.  This interprets the
String argument as a URI, and will be trying to load data
from that.

If you try saxParser.parse(source, this) you might have a bit
more luck...



(PS.  Why are you loading the data into memory first?  The parser
works perfectly well parsing data directly from a stream)


Hope this helps,

   Thomas.