org.xml.sax.SAXException#getLocalizedMessage ( )源码实例Demo

下面列出了org.xml.sax.SAXException#getLocalizedMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: DOMConvertor.java
/** Read content from <code>r</code> and delegate to {@link #readElement}
 * passing parsed content as a root element of DOM document
 * @param r stream containing stored object
 * @return the read setting object
 * @exception IOException if the object cannot be read
 * @exception ClassNotFoundException if the object class cannot be resolved
 * @since 1.1
 */
public final Object read(java.io.Reader r) throws java.io.IOException, ClassNotFoundException {
    Document doc = null;
    try {
        InputSource is = new InputSource(r);
        doc = XMLUtil.parse(is, false, false, null, org.openide.xml.EntityCatalog.getDefault());
        setDocumentContext(doc, findContext(r));
        return readElement(doc.getDocumentElement());
    } catch (SAXException ex) {
        IOException ioe = new IOException(ex.getLocalizedMessage());
        ioe.initCause(ex);
        throw ioe;
    } finally {
        if (doc != null) {
            clearCashesForDocument(doc);
        }
    }
}
 
@Override
public void process(final InputStream stream) throws IOException {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(isNamespaceAware);
        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.parse(stream);
    } catch (ParserConfigurationException pce) {
        throw new IOException(pce.getLocalizedMessage(), pce);
    } catch (SAXException saxe) {
        throw new IOException(saxe.getLocalizedMessage(), saxe);
    }
}
 
private String getText(SAXException e) {
    if (e instanceof SAXParseException) {
        return ((SAXParseException) e).getLineNumber() + ": "
                + e.getLocalizedMessage();
    } else {
        return e.getMessage();
    }
}
 
源代码4 项目: cxf   文件: JAXBDataBinding.java
public void validateSchema(Element ele,
                           String uri,
                           final OASISCatalogManager catalog,
                           final SchemaCollection schemaCollection) throws ToolException {
    SchemaFactory schemaFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    schemaFact.setResourceResolver(new LSResourceResolver() {
        public LSInput resolveResource(String type,
                                       String namespaceURI,
                                       String publicId,
                                       String systemId,
                                       String baseURI) {
            String s = JAXBDataBinding.mapSchemaLocation(systemId, baseURI, catalog);
            LOG.fine("validating: " + namespaceURI + " " + systemId + " " + baseURI + " " + s);
            if (s == null) {
                XmlSchema sc = schemaCollection.getSchemaByTargetNamespace(namespaceURI);
                if (sc != null) {
                    StringWriter writer = new StringWriter();
                    sc.write(writer);
                    InputSource src = new InputSource(new StringReader(writer.toString()));
                    src.setSystemId(sc.getSourceURI());
                    return new LSInputSAXWrapper(src);
                }
                throw new ToolException("Schema not found for namespace: " + namespaceURI);
            }
            return new LSInputSAXWrapper(new InputSource(s));
        }
    });
    DOMSource domSrc = new DOMSource(ele, uri);
    try {
        schemaFact.newSchema(domSrc);
    } catch (SAXException e) {
        if (e.getLocalizedMessage().indexOf("src-resolve.4.2") > -1)  {
            //Ignore schema resolve error and do nothing
        } else {
            //e.printStackTrace();
            throw new ToolException("Schema Error : " + e.getLocalizedMessage(), e);
        }
    }
}
 
源代码5 项目: nifi   文件: DocumentReaderCallback.java
@Override
public void process(final InputStream stream) throws IOException {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(isNamespaceAware);
        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.parse(stream);
    } catch (ParserConfigurationException pce) {
        throw new IOException(pce.getLocalizedMessage(), pce);
    } catch (SAXException saxe) {
        throw new IOException(saxe.getLocalizedMessage(), saxe);
    }
}