Set saxon DocumentBuilderFactoryImpl features using javax.xml interface.

Posted by Mycol on Stack Overflow See other posts from Stack Overflow or by Mycol
Published on 2010-05-29T09:02:27Z Indexed on 2010/05/29 12:42 UTC
Read the original article Hit count: 424

Filed under:
|
|

Here what I have.

      System.setProperty(
    "javax.xml.parsers.DocumentBuilderFactory",
  "net.sf.saxon.dom.DocumentBuilderFactoryImpl");


  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  //factory.setNamespaceAware(true);
  //factory.setIgnoringElementContentWhitespace(true);
  //factory.setValidating(false);
  //factory.setIgnoringComments(true);

  DocumentBuilder builder = factory.newDocumentBuilder();
  Document xml = builder.parse(file.getAbsolutePath());

Saxon parser doesn't allow me to set the commentet properties:

    javax.xml.parsers.ParserConfigurationException: Saxon parser does not allow whitespace in element content to be ignored
 at net.sf.saxon.dom.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:98)

I thought i could set those features in other way, like

factory.setAttribute(string, bool)
factory.setFeature(string, bool)

But I can't find anywhere the values for "string". I tried net.sf.saxon.FeatureKeys whitout success.

My question is: what's the correct way to do that?

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml