Example usage for org.xml.sax SAXParseException getMessage

List of usage examples for org.xml.sax SAXParseException getMessage

Introduction

In this page you can find the example usage for org.xml.sax SAXParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Return a detail message for this exception.

Usage

From source file:Main.java

public static Element loadDocument(Reader target) {
    Document doc = null;//from  ww  w.j a va  2 s .  c  o m
    try {
        InputSource xmlInp = new InputSource(target);

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(xmlInp);
        Element root = doc.getDocumentElement();
        root.normalize();
        return root;
    } catch (SAXParseException err) {
        System.err.println("URLMappingsXmlDAO ** Parsing error, line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        System.err.println("URLMappingsXmlDAO error: " + err.getMessage());
    } catch (SAXException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (MalformedURLException mfx) {
        System.err.println("URLMappingsXmlDAO error: " + mfx);
    } catch (IOException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (Exception pce) {
        System.err.println("URLMappingsXmlDAO error: " + pce);
    }
    return null;
}

From source file:Main.java

public static Element loadDocument(Reader target) {
    Document doc = null;/*w  w w  .ja  v a  2 s  .c  om*/
    try {
        InputSource xmlInp = new InputSource(target);

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(xmlInp);
        Element root = doc.getDocumentElement();
        root.normalize();
        return root;
    } catch (SAXParseException err) {
        System.err.println("URLMappingsXmlDAO ** Parsing error" + ", line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        System.err.println("URLMappingsXmlDAO error: " + err.getMessage());
    } catch (SAXException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (java.net.MalformedURLException mfx) {
        System.err.println("URLMappingsXmlDAO error: " + mfx);
    } catch (java.io.IOException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (Exception pce) {
        System.err.println("URLMappingsXmlDAO error: " + pce);
    }
    return null;
}

From source file:Main.java

public static Element loadDocument(String location) {
    Document doc = null;/*  w  w  w. java  2s  .c om*/
    try {
        URL url = new URL(location);
        InputSource xmlInp = new InputSource(url.openStream());

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(xmlInp);
        Element root = doc.getDocumentElement();
        root.normalize();
        return root;
    } catch (SAXParseException err) {
        System.err.println("URLMappingsXmlDAO ** Parsing error" + ", line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        System.err.println("URLMappingsXmlDAO error: " + err.getMessage());
    } catch (SAXException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (java.net.MalformedURLException mfx) {
        System.err.println("URLMappingsXmlDAO error: " + mfx);
    } catch (java.io.IOException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (Exception pce) {
        System.err.println("URLMappingsXmlDAO error: " + pce);
    }
    return null;
}

From source file:Main.java

public static Element loadDocument(String value, String type) {
    Document doc = null;/*ww w  . ja va  2 s .  co m*/
    InputSource xmlInp = null;
    try {
        if (type.equals("location")) {
            URL url = new URL(value);
            xmlInp = new InputSource(url.openStream());
        } else {
            xmlInp = new InputSource(new StringReader(value));
        }
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(xmlInp);
        Element root = doc.getDocumentElement();
        root.normalize();
        return root;
    } catch (SAXParseException err) {
        System.err.println("URLMappingsXmlDAO ** Parsing error, line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        System.err.println("URLMappingsXmlDAO error: " + err.getMessage());
    } catch (SAXException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (MalformedURLException mfx) {
        System.err.println("URLMappingsXmlDAO error: " + mfx);
    } catch (IOException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (Exception pce) {
        System.err.println("URLMappingsXmlDAO error: " + pce);
    }
    return null;
}

From source file:Main.java

public static Element loadDocument(File location) {
    Document doc = null;/*w w  w  .j a  v  a  2 s  .  c  om*/
    try {

        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
        doc = parser.parse(location);
        Element root = doc.getDocumentElement();
        root.normalize();
        /*
         * //Output to standard output ; use Sun's reference imple for now
         * XmlDocument xdoc = (XmlDocument) doc; xdoc.write(new
         * OutputStreamWriter(System.out));
         */
        return root;
    } catch (SAXParseException err) {
        System.err.println("URLMappingsXmlDAO ** Parsing error" + ", line " + err.getLineNumber() + ", uri "
                + err.getSystemId());
        System.err.println("URLMappingsXmlDAO error: " + err.getMessage());
    } catch (SAXException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (java.net.MalformedURLException mfx) {
        System.err.println("URLMappingsXmlDAO error: " + mfx);
    } catch (java.io.IOException e) {
        System.err.println("URLMappingsXmlDAO error: " + e);
    } catch (Exception pce) {
        System.err.println("URLMappingsXmlDAO error: " + pce);
    }
    return null;
}

From source file:eu.delving.x3ml.X3MLEngine.java

private static String errorMessage(SAXParseException e) {
    return String.format("%d:%d - %s", e.getLineNumber(), e.getColumnNumber(), e.getMessage());
}

From source file:es.mityc.firmaJava.libreria.utilidades.AnalizadorFicheroFirma.java

public static void mostrarError(SAXParseException exc, String aviso) throws SAXException {
    log.error(aviso);/*from w  w w  .java  2  s  .  c  om*/
    log.error(LINE_DOS_PUNTOS + exc.getLineNumber());
    log.error(URI_DOS_PUNTOS + exc.getSystemId());
    log.error(I18n.getResource(LIBRERIA_UTILIDADES_ANALIZADOR_ERROR_3) + exc.getMessage());
    throw new SAXException(aviso);
}

From source file:Main.java

public static Document openXmlFile(File file, Schema schema, boolean isNamespaceAware, boolean isXIncludeAware)
        throws IOException, SAXParseException, SAXException {
    final String fname = file.getCanonicalPath();
    DocumentBuilder builder = newDocumentBuilder(schema, isNamespaceAware, isXIncludeAware);
    Document docu;/*from   w w  w .j a  v  a2s . co  m*/

    builder.setErrorHandler(new org.xml.sax.ErrorHandler() {
        @Override
        public void error(SAXParseException exception) throws SAXParseException {
            //System.err.println("Parse Error in file " + fname + ", line " + exception.getLineNumber() + ": " + exception.getMessage());
            throw new SAXParseException("Parse Error in file " + fname + ", line " + exception.getLineNumber()
                    + ": " + exception.getMessage(), "", fname, exception.getLineNumber(), 0);
        }

        @Override
        public void fatalError(SAXParseException exception) throws SAXParseException {
            //System.err.println("Parse Fatal Error: " + exception.getMessage() + exception.getLineNumber());
            throw new SAXParseException("Parse Error in file " + fname + ", line " + exception.getLineNumber()
                    + ": " + exception.getMessage(), "", fname, exception.getLineNumber(), 0);
        }

        @Override
        public void warning(SAXParseException exception) {
            System.err.println("Parse Warning: " + exception.getMessage() + exception.getLineNumber());
        }
    });

    docu = builder.parse(file);
    return docu;
}

From source file:net.ontopia.topicmaps.entry.XMLConfigSource.java

private static List<TopicMapSourceIF> readSources(InputSource inp_source, Map<String, String> environ) {
    ConfigHandler handler = new ConfigHandler(environ);

    try {//w  ww. j av  a  2  s.co  m
        XMLReader parser = DefaultXMLReaderFactory.createXMLReader();
        parser.setContentHandler(handler);
        parser.setErrorHandler(new Slf4jSaxErrorHandler(log));
        parser.parse(inp_source);
    } catch (SAXParseException e) {
        String msg = "" + e.getSystemId() + ":" + e.getLineNumber() + ":" + e.getColumnNumber() + ": "
                + e.getMessage();
        throw new OntopiaRuntimeException(msg, e);
    } catch (Exception e) {
        throw new OntopiaRuntimeException(e);
    }
    return handler.sources;
}

From source file:com.puppycrawl.tools.checkstyle.ConfigurationLoader.java

/**
 * Returns the module configurations from a specified input source.
 * Note that if the source does wrap an open byte or character
 * stream, clients are required to close that stream by themselves
 *
 * @param configSource the input stream to the Checkstyle configuration
 * @param overridePropsResolver overriding properties
 * @param omitIgnoredModules {@code true} if modules with severity
 *            'ignore' should be omitted, {@code false} otherwise
 * @return the check configurations//from   ww w . j a v  a2 s .  c om
 * @throws CheckstyleException if an error occurs
 */
public static Configuration loadConfiguration(InputSource configSource, PropertyResolver overridePropsResolver,
        boolean omitIgnoredModules) throws CheckstyleException {
    try {
        final ConfigurationLoader loader = new ConfigurationLoader(overridePropsResolver, omitIgnoredModules);
        loader.parseInputSource(configSource);
        return loader.configuration;
    } catch (final SAXParseException e) {
        final String message = String.format(Locale.ROOT, "%s - %s:%s:%s", UNABLE_TO_PARSE_EXCEPTION_PREFIX,
                e.getMessage(), e.getLineNumber(), e.getColumnNumber());
        throw new CheckstyleException(message, e);
    } catch (final ParserConfigurationException | IOException | SAXException e) {
        throw new CheckstyleException(UNABLE_TO_PARSE_EXCEPTION_PREFIX, e);
    }
}