Disable XML validation in java 5


General J2EE: Disable XML validation in java 5

  1. Disable XML validation in java 5 (2 messages)

    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

    Threaded Messages (2)

  2. Re: Disable XML validation in java 5[ Go to top ]

    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?
  3. answer[ Go to top ]

    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