Example usage for javax.xml.parsers DocumentBuilderFactory isIgnoringComments

List of usage examples for javax.xml.parsers DocumentBuilderFactory isIgnoringComments

Introduction

In this page you can find the example usage for javax.xml.parsers DocumentBuilderFactory isIgnoringComments.

Prototype


public boolean isIgnoringComments() 

Source Link

Document

Indicates whether or not the factory is configured to produce parsers which ignores comments.

Usage

From source file:org.apache.xml.security.test.signature.ECDSASignatureTest.java

protected void setUp() throws Exception {
    ////  ww  w . j  ava 2 s .co m
    // If the BouncyCastle provider is not installed, then try to load it 
    // via reflection. If it is not available, then skip this test as it is
    // required for elliptic curves
    //
    if (Security.getProvider("BC") == null) {
        Constructor cons = null;
        try {
            Class c = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
            cons = c.getConstructor(new Class[] {});
        } catch (Exception e) {
            //ignore
        }
        if (cons == null) {
            // BouncyCastle is not available so just return
            return;
        } else {
            Security.addProvider((java.security.Provider) cons.newInstance(new Object[] {}));
        }
    }

    javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    log.info("dbf.isIgnoringComments()=" + dbf.isIgnoringComments());
    log.info("dbf.isIgnoringElementContentWhitespace()=" + dbf.isIgnoringElementContentWhitespace());

    String id = "http://apache.org/xml/properties/dom/document-class-name";

    dbf.setAttribute(id, IndexedDocument.class.getName());

    db = dbf.newDocumentBuilder();
    org.apache.xml.security.Init.init();
}