In the xerces.jar that ships with WSAD 5.1
(C:\wsad51\eclipse\plugins\org.apache.xerces_4.0.13\xercesImpl.jar (1,176,093
bytes), I've found the parser doesn't appear to handle the end of inputsource
correctly, when it is constructed from a String, throwing an exception where the
line number is -1. I've coded a workaround, but wondered if this is known
and fixed, or if there is a better way to deal with this issue.
public void instantiateFrom(String strXML, ArrayList retList)
throws XYZException {
public void instantiateFrom(String strXML, ArrayList retList)
throws XYZException {
StringReader reader = new
StringReader(strXML);
InputSource inputSource = new InputSource(reader);
InputSource inputSource = new InputSource(reader);
m_List = retList;
m_Parser.setContentHandler(this);
m_Parser.setErrorHandler(this);
try {
m_Parser.parse(inputSource);
} catch (SAXParseException e) {
// handle end of file
if (e.getLineNumber() != -1) {
throw new XYZException(formatSAXParseException(e), e);
} // else expected case due to reaching the end of the string
} catch (SAXException e) {
throw new XYZException(e.getLocalizedMessage(), e);
} catch (IOException e) {
throw new XYZException(e.getLocalizedMessage(), e);
}
}
m_Parser.setContentHandler(this);
m_Parser.setErrorHandler(this);
try {
m_Parser.parse(inputSource);
} catch (SAXParseException e) {
// handle end of file
if (e.getLineNumber() != -1) {
throw new XYZException(formatSAXParseException(e), e);
} // else expected case due to reaching the end of the string
} catch (SAXException e) {
throw new XYZException(e.getLocalizedMessage(), e);
} catch (IOException e) {
throw new XYZException(e.getLocalizedMessage(), e);
}
}