File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes continuing with the deprecated problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "continuing with the deprecated problem." Watch "continuing with the deprecated problem." New topic

continuing with the deprecated problem.

anand chouti

Joined: May 10, 2004
Posts: 5
Initially I used the DocumentHandler which is deprecated now. The code is as below.
//code starts here
public class ValidateSAXParser implements DocumentHandler {
public void saxParser(String sRequestXML) throws InvalidXMLException {
try {
StringBufferInputStream stringBufferInStream = new StringBufferInputStream(sRequestXML);
InputSource inputSource = new InputSource((InputStream) stringBufferInStream);
Parser parser;
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
parser = sp.getParser();
objDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (SAXParseException err) {
throw new InvalidXMLException(ExceptionConstants.AIRBUS_HPGPARTS_INVALID_XML_EXCEPTION);
} catch (Throwable t) {
throw new InvalidXMLException(ExceptionConstants.AIRBUS_HPGPARTS_INVALID_XML_EXCEPTION);
// code ends here

But now I use the ContentHandler in place of DocumentHandler and XMLReader in place of Parser. But there are problems all around. What do i do for the
following line :
And also what are the other changes to be made.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962


And make the class referred to by "this" extend org.xml.sax.helpers.DefaultHandler, i.e.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
I agree. Here's the link:
subject: continuing with the deprecated problem.
It's not a secret anymore!