[jdom-interest] Passing CharArrayReader to SAXBuilder build() method

Mark S Petrovic petrovic at corp.earthlink.net
Fri Dec 21 12:38:19 PST 2001


Good day.  I am an old C programmer who is new to Java and JDOM.

I've managed to read an XML document from a socket stream and cast
it into the character array, TASResult.  My reading of the build()
method API of SAXBuilder suggests that I can pass any type of Reader
object, which presumably includes CharArrayReader, as follows:

CharArrayReader cr = new CharArrayReader(TASresult);
SAXBuilder builder = new SAXBuilder(true);
Document doc = builder.build(cr);

The code compiles, but produces this at runtime

$ java avlclient "/cur?id=DEMO003&typ=x"  
org.xml.sax.SAXParseException: Illegal XML character:  �.
        at org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1097)
        at org.apache.crimson.parser.InputEntity.getc(InputEntity.java:360)
        at org.apache.crimson.parser.Parser2.getc(Parser2.java:2980)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:506)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:287)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:650)
        at avlclient.main(avlclient.java:98)

I suspect that the read() method of CharArrayReader is passing back
something that the build() method misinterprets.

Might someone be kind enough to explain to me why what I attempt
does not produce the desired result?

Thank you.



More information about the jdom-interest mailing list