this is my first time using StAX to parse XML documents (still in training). During the process of parsing an XML document using XMLStreamReader and creating a copy of the document using XMLStreamWriter, I found the following warning, presented as a comment on the output of the record:
I understood the reason for the warning, but I wanted it to become a mistake, and not tacitly become a warning, so I tried to set XMLInputFactory.IS_VALIDATING to true:
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.TRUE);
But the above made an exception for me:
Exception in thread "main" java.lang.IllegalArgumentException: true value isValidating not supported in com.sun.org.apache.xerces.internal.impl.PropertyManager.setProperty (PropertyManager.java:150) in com.sun.xml.internal .stream.XMLInputFactoryImpl.setProperty (XMLInputFactoryImpl.java:257) in com.test.test2.helper.SgmlDocumentParser.parse (SgmlDocumentParser.java:83) in com.test.test2.helper.Test.main (Test.java:66 )
So what is wrong with my approach?
Thanks!
source
share