Srikanth Sridhar Srikanth Sridhar - 1 month ago 22
Java Question

How to set FEATURE_SECURE_PROCESSING in XMLReaderFactory?

I am using Piccolo jar and creating XML reader using XMLReaderFactory.
I need to set the secure processing feature and hence i did this way,

xmlReader = XMLReaderFactory.createXMLReader("com.bluecast.xml.Piccolo");
xmlReader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);


But this is throwing error
org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing
at com.bluecast.xml.Piccolo.setFeature(Piccolo.java:937)


I had an old xercesImpl.jar which has been replaced by xercesImpl-2.9.1.jar but still getting the same error. I googled and din't find any concrete solutions.

Please help, Any ideas are appreciable.

Thanks,
Srikanth

Answer

So the constant XMLConstants.FEATURE_SECURE_PROCESSING has value http://javax.xml.XMLConstants/feature/secure-processing

According to the source code here (the latest is 1.04), a big if else block checks to see what if this value is one of the allowable features and if not throws this exception. And in fact, it is not one of the values judged to be legal and therefore the exception is thrown.

As per SaxParserFactory, we read

All implementations are required to support the javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING feature.

Piccolo implements Parser though and not SaxParser. So all in all I would say Piccolo does not support that feature. Perhaps I would say use a different XMLReader which does support it.

Comments