aspose file tools*
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "continuing with the deprecated problem." Watch "continuing with the deprecated problem." New topic
Author

continuing with the deprecated problem.

anand chouti
Greenhorn

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();
spf.setValidating(this.bValidate);
SAXParser sp = spf.newSAXParser();
parser = sp.getParser();
parser.setDocumentHandler(this);
objDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
parser.parse(inputSource);
} 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 :
spf.setValidating(this.bValidate);
And also what are the other changes to be made.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Change

into

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: http://aspose.com/file-tools
 
subject: continuing with the deprecated problem.