i'm getting below error while setting the feature for TransformerFactory.
javax.xml.transform.TransformerConfigurationException: Cannot set the feature 'http://apache.org/xml/features/disallow-doctype-decl' on this TransformerFactory.
at org.apache.xalan.processor.TransformerFactoryImpl.setFeature(TransformerFactoryImpl.java:416)
Code snippet is::
public static TransformerFactory mytFactory;
mytFactory = TransformerFactory.newInstance();
mytFactory.setFeature(“http://apache.org/xml/features/disallow-doctype-decl“, true);
please help me to solve this issue.
I have also failed to call method "setFeature" of TransformerFactoryImpl. And I found other way to set feature by using XMLReader as below:
After that setting, if the input has DOCTYPE tag inside, we will have following exception:
Hope that it's helpful for you.