Example usage for javax.xml.parsers ParserConfigurationException printStackTrace

List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.parsers ParserConfigurationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

/**
 * Creates an empty DOM Document.//from   w  w w .  ja va 2s . c o  m
 * @return Document - the created document
 */
public static Document createEmptyDocument() {
    DocumentBuilder builder;
    try {
        builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        return builder.newDocument();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

static public Document newDocument() {
    Document document = null;/*from   w w  w . j  a v a 2s.  c o  m*/
    DocumentBuilder builder = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try {
        builder = factory.newDocumentBuilder();
        document = builder.newDocument();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }

    return document;
}

From source file:Main.java

public static Document CreateDocument() {
    try {//from  w  w w .  j a  v a  2  s. com
        return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (FactoryConfigurationError e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

private static void setFeature(DocumentBuilderFactory factory, String feature) {
    try {/*from  w ww  .j  a v  a2s  . c o m*/
        factory.setFeature(feature, false);
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 *
 * @return//w  w  w . ja v  a2 s  .  co  m
 */
public static Document getNewDocument() {
    Document document = null;
    try {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        document = documentBuilder.newDocument();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }

    return document;
}

From source file:Main.java

public static final Document createDocument(boolean standalone, String xmlVersion) {
    Document result = null;/*from  w  ww .j a v a  2 s . com*/

    try {

        result = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        result.setXmlStandalone(standalone);
        result.setXmlVersion(xmlVersion);
    } catch (ParserConfigurationException e) {

        e.printStackTrace();
    }

    return result;
}

From source file:Main.java

public static Element GetXmlDocFromStr(String xmlStr) {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = null;//from  w  ww.  j  a va 2 s .  c o m
    try {
        db = dbf.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    }
    Document doc = null;
    try {
        InputStream inputStream = new ByteArrayInputStream(xmlStr.getBytes());
        doc = db.parse(inputStream);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return (Element) doc.getDocumentElement();
}

From source file:Main.java

public static Document parseXMLFile(String file) {

    try {//from   w  w w. j av  a2  s  .com
        File mappingsFile = new File(file);
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(mappingsFile);
        return doc;
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

/**
 * Creates an empty JAXP XML document./*from   w  w w .  j a v a 2  s .  c  o m*/
 * 
 * @return An empty JAXP XML document.
 */
public static Document getNewEmptyJAXPDoc() {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder;

    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        return documentBuilder.newDocument();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:Main.java

static DocumentBuilder makeDOMparser() {
    DocumentBuilder parser = null;
    try {//w  w w. jav a  2  s  .com
        DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
        dbfactory.setIgnoringElementContentWhitespace(true);
        parser = dbfactory.newDocumentBuilder();
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
        System.exit(1);
    }
    return parser;
}