Example usage for org.xml.sax SAXParseException getSystemId

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

Introduction

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

Prototype

public String getSystemId() 

Source Link

Document

Get the system identifier of the entity where the exception occurred.

Usage

From source file:org.vulpe.commons.xml.XMLReader.java

public List<XMLAttribute> reader(final String xml) {
    final List<XMLAttribute> attributeList = new ArrayList<XMLAttribute>();
    if (StringUtils.isNotEmpty(xml)) {
        try {//w  w w.  j a  va2 s  .co m
            final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            final DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            final ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf-8"));
            final Document document = docBuilder.parse(bais);
            final Node entity = document.getChildNodes().item(0);
            final NodeList atributos = entity.getChildNodes();
            for (int i = 0; i < atributos.getLength(); i++) {
                final String attribute = atributos.item(i).getNodeName();
                if (!"#text".equals(attribute)) {
                    final String value = getChildTagValue((Element) entity, attribute);
                    attributeList.add(new XMLAttribute(attribute, value));
                }
            }
        } catch (SAXParseException err) {
            LOG.error("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
            LOG.error(" " + err.getMessage());
        } catch (SAXException e) {
            final Exception exception = e.getException();
            LOG.error(((exception == null) ? e.getMessage() : exception.getMessage()));
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }
    }
    return attributeList;
}

From source file:org.webcurator.domain.MockPermissionTemplateDAO.java

public MockPermissionTemplateDAO(String filename) {

    super();/*from  w ww .  j  a v a2 s  .  c o m*/
    try {
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        theFile = docBuilder.parse(new File(filename));

        NodeList permissionNodes = theFile.getElementsByTagName("permission");

        // force a nested load of everything
        // loadPermissionsFromNodeList(permissionNodes);
    } catch (SAXParseException err) {
        log.debug("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
        log.debug(" " + err.getMessage());
    } catch (SAXException se) {
        Exception x = se.getException();
        ((x == null) ? se : x).printStackTrace();
    } catch (Exception e) {
        log.debug(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:org.wso2.carbon.bpel.common.LoggingErrorHandler.java

private String formatMessage(String level, SAXParseException spe) {
    StringBuilder sb = new StringBuilder(64);

    if (spe.getSystemId() != null) {
        sb.append(spe.getSystemId());/*from  w  ww.  j av a 2  s. com*/
    }

    sb.append(':');
    sb.append(spe.getLineNumber());
    sb.append(':');
    sb.append(spe.getColumnNumber());
    sb.append(':');
    sb.append(level);
    sb.append(':');
    sb.append(spe.getMessage());

    return sb.toString();
}

From source file:org.yawlfoundation.yawl.unmarshal.YawlXMLSpecificationValidator.java

private String getLineNumber(SAXParseException e) {
    return (e.getSystemId() != null) ? "[ln: " + e.getLineNumber() + " col: " + e.getColumnNumber() + "]" : "";
}

From source file:stroom.pipeline.server.filter.SchemaFilter.java

/**
 * @see stroom.pipeline.server.filter.AbstractXMLFilter#startProcessing()
 *///from   www .j  a  va  2  s  .  co  m
@Override
public void startProcessing() {
    try {
        if (errorHandler == null) {
            errorHandler = new ErrorHandlerAdaptor(getElementId(), locationFactory, errorReceiverProxy) {
                @Override
                protected void log(final Severity severity, final SAXParseException exception) {
                    String message = exception.getMessage();

                    if (message.contains("cvc-")) {
                        message = CVC_PATTERN.matcher(message).replaceAll("");
                    }
                    if (message.contains("One of")) {
                        message = NS_REDUCTION_PATTERN.matcher(message).replaceAll("");
                    }
                    message = message.trim();

                    final SAXParseException ex = new SAXParseException(message, exception.getPublicId(),
                            exception.getSystemId(), exception.getLineNumber(), exception.getColumnNumber());

                    super.log(severity, ex);
                }
            };
        }

        schemaLocations = null;
        prefixes.clear();
        validator = null;
    } finally {
        super.startProcessing();
    }
}

From source file:uk.ac.ebi.bioinvindex.utils.datasourceload.DataSourceLoader.java

public void loadAll(InputStream inputStream) throws InvalidConfigurationException {

    ReferenceSource isaTabSource = null;
    Collection<AssayTypeDataLocation> locations = null;
    try {//from   www .jav  a 2s.c  o m
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(inputStream);

        // normalize text representation
        doc.getDocumentElement().normalize();

        isaTabSource = parseISATabLocation(doc);
        locations = parseDataSources(doc);

    } catch (SAXParseException err) {
        throw new InvalidConfigurationException("Parsing error" + ", line " + err.getLineNumber() + ", uri "
                + err.getSystemId() + ":" + err.getMessage(), err);
    } catch (SAXException e) {
        throw new InvalidConfigurationException(
                "Invalid data file location configuration file:" + e.getMessage(), e);
    } catch (IOException e) {
        throw new InvalidConfigurationException(
                "Invalid data file location configuration file" + e.getMessage(), e);
    } catch (ParserConfigurationException e) {
        throw new InvalidConfigurationException(
                "Invalid data file location configuration file" + e.getMessage(), e);
    }

    persistLocations(isaTabSource, locations);

}