Search in sources :

Example 1 with ModelRuntimeException

use of org.ontoware.rdf2go.exception.ModelRuntimeException in project stanbol by apache.

the class XsltExtractor method extract.

public synchronized void extract(String id, Document doc, Map<String, Object> params, RDFContainer result) throws ExtractorException {
    if (params == null) {
        params = new HashMap<String, Object>();
    }
    params.put(this.uriParameter, id);
    initTransformerParameters(params);
    Source source = new DOMSource(doc);
    StringWriter writer = new StringWriter();
    StreamResult output = new StreamResult(writer);
    try {
        this.transformer.transform(source, output);
        String rdf = writer.toString();
        LOG.debug(rdf);
        StringReader reader = new StringReader(rdf);
        result.getModel().readFrom(reader, this.syntax);
        reader.close();
    } catch (TransformerException e) {
        throw new ExtractorException(e.getMessage(), e);
    } catch (ModelRuntimeException e) {
        throw new ExtractorException(e.getMessage(), e);
    } catch (IOException e) {
        throw new ExtractorException(e.getMessage(), e);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) StringReader(java.io.StringReader) ExtractorException(org.semanticdesktop.aperture.extractor.ExtractorException) ModelRuntimeException(org.ontoware.rdf2go.exception.ModelRuntimeException) IOException(java.io.IOException) DOMSource(javax.xml.transform.dom.DOMSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) TransformerException(javax.xml.transform.TransformerException)

Aggregations

IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Source (javax.xml.transform.Source)1 TransformerException (javax.xml.transform.TransformerException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 StreamSource (javax.xml.transform.stream.StreamSource)1 ModelRuntimeException (org.ontoware.rdf2go.exception.ModelRuntimeException)1 ExtractorException (org.semanticdesktop.aperture.extractor.ExtractorException)1