Example usage for org.xml.sax.ext Locator2Impl Locator2Impl

List of usage examples for org.xml.sax.ext Locator2Impl Locator2Impl

Introduction

In this page you can find the example usage for org.xml.sax.ext Locator2Impl Locator2Impl.

Prototype

public Locator2Impl() 

Source Link

Document

Construct a new, empty Locator2Impl object.

Usage

From source file:eu.elf.license.LicenseParser.java

/**
 * Creates DOM Document object from XML string
 *
 * @param xmlString//  w w  w  .  j  a  v a 2s.  c  om
 * @return xml document
 * @throws Exception
 */
public static Document createXMLDocumentFromString(String xmlString) throws Exception {
    Document document = null;

    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);

        DocumentBuilder builder = dbf.newDocumentBuilder();
        InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
        document = builder.parse(is);

    } catch (SAXParseException spe) {
        Locator2Impl locator = new Locator2Impl();
        spe.printStackTrace();
        throw new SAXParseException("", locator);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return document;
}