Hi Everybody, How can I disable XML validation in java 5 parser? It simply does not work... This is my code: DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); factory.setAttribute("http://xml.org/sax/features/validation",Boolean.FALSE); factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd",Boolean.FALSE); DocumentBuilder builder = factory.newDocumentBuilder(); Thanks, Maciej
- Posted by: Maciej Miklas
- Posted on: September 11 2007 08:04 EDT
I assume you're talking about XML Schema validation. If it's well-formedness checks you want to disable, then how should the parser deliver a valid Document object? Disabling schema validation should be easy, as enabling it usually takes some effort. Why do you think your code is validating? Does builder.isValidating() return true, do you get Schema validation errors, which Exception is thrown by the parser?
it connects to the internet for dtd. On my server there is no internet connection, so it waist for timeout - like 10 seconds. If I remove the dtd part from xml, the parsing is very fast. I need to keep dtd part in xml, but I do not want it to be validated. regards, Maciej