Java 8 DocumentBuilderFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DocumentBuilderFactory class.

This code example shows how to use the following methods: setCoalescing, setExpandEntityReferences, setIgnoringComments, setIgnoringElementContentWhitespace, setNamespaceAware
        xmlPullParserFactory.setNamespaceAware(true);
        xmlPullParserFactory.setValidating(false);
 
        documentBuilderFactory = DocumentBuilderFactory.newInstance();
        // XMPP requires namespace awareness 
        documentBuilderFactory.setNamespaceAware(true);
        // slightly normalize 
        documentBuilderFactory.setCoalescing(true);
        documentBuilderFactory.setIgnoringComments(true);
        documentBuilderFactory.setIgnoringElementContentWhitespace(false);
        // No includes / outbound references 
        documentBuilderFactory.setExpandEntityReferences(false);
        documentBuilderFactory.setValidating(false);
    } 
 
    /** 
     * Read a stanza from a xml stream. This does not include the connection 
     * related stanza settings like the via tag. 
     * @param xmlPullParser The XML PullParser of the current stream. 
     * @return The read stanza. 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getClass, newDocumentBuilder
	public Document loadDocument(InputSource inputSource, EntityResolver entityResolver,
			ErrorHandler errorHandler, int validationMode, boolean namespaceAware) throws Exception {
 
		DocumentBuilderFactory factory = createDocumentBuilderFactory(validationMode, namespaceAware);
		if (logger.isDebugEnabled()) {
			logger.debug("Using JAXP provider [" + factory.getClass().getName() + "]");
		} 
		DocumentBuilder builder = createDocumentBuilder(factory, entityResolver, errorHandler);
		return builder.parse(inputSource);
	} 
 
	/** 
	 * Create the {@link DocumentBuilderFactory} instance. 
	 * @param validationMode the type of validation: {@link XmlValidationModeDetector#VALIDATION_DTD DTD} 
	 * or {@link XmlValidationModeDetector#VALIDATION_XSD XSD}) 
	 * @param namespaceAware whether the returned factory is to provide support for XML namespaces 
	 * @return the JAXP DocumentBuilderFactory 
	 * @throws ParserConfigurationException if we failed to build a proper DocumentBuilderFactory 
	 */ 
	protected DocumentBuilderFactory createDocumentBuilderFactory(int validationMode, boolean namespaceAware)

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: newDocumentBuilder, setNamespaceAware
This code example shows how to use the following methods: setAttribute, setNamespaceAware, setValidating
 
   static { 
 
      documentBuilderFactory = DocumentBuilderFactory.newInstance();
 
      documentBuilderFactory.setAttribute(
               "http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); 
      documentBuilderFactory.setAttribute(
               "http://apache.org/xml/features/nonvalidating/load-external-dtd", false); 
 
      documentBuilderFactory.setNamespaceAware(false);
      documentBuilderFactory.setValidating(false);
 
   } 
 
   /** 
    * Creates a new DocumentBuilder which does not validate document an is not aware of XML 
    * namespaces. 
    *  
    * @return The created DocumentBuilder 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: newDocumentBuilder, setNamespaceAware, setValidating
            if ( dbf == null ) {
                dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware( true );
                dbf.setValidating( false );
            } 
            db = dbf.newDocumentBuilder();
 
            DOMImplementation dim = db.getDOMImplementation();
            d = dim.createDocument("http://java.sun.com/jaxp/xpath",
                "dummyroot", null); 
            return d;
        } catch ( Exception e ) {
            e.printStackTrace();
        } 
        return null; 
    } 
 
 
 
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 DocumentBuilderFactory Questions & Answers:

Other Java 8 DocumentBuilderFactory Examples

1:			Document doc = null;
2:			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
3:			try {
4:

Read More

63:			Document doc = null;
64:			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
65:			try {
66:	
67:				DocumentBuilder db = dbf.newDocumentBuilder();

Read More

63:			Document doc = null;
64:			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
65:			try {
66:	
67:				DocumentBuilder db = dbf.newDocumentBuilder();

Read More

See Code Examples for Java 8 DocumentBuilderFactory Methods: