Search in sources :

Example 1 with EXIResult

use of com.siemens.ct.exi.api.sax.EXIResult in project arctic-sea by 52North.

the class XmlToExiConverter method encode.

protected void encode(String fileName) {
    try (InputStream exiIS = FileUtils.openInputStream(getFile(fileName, XML_EXTENSION));
        OutputStream exiOS = FileUtils.openOutputStream(getFile(fileName, EXI_EXTENSION))) {
        EXIResult exiResult = new EXIResult();
        exiResult.setOutputStream(exiOS);
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setContentHandler(exiResult.getHandler());
        xmlReader.parse(new InputSource(exiIS));
    } catch (Exception e) {
    // TODO: handle exception
    }
}
Also used : EXIResult(com.siemens.ct.exi.api.sax.EXIResult) InputSource(org.xml.sax.InputSource) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) XMLReader(org.xml.sax.XMLReader)

Example 2 with EXIResult

use of com.siemens.ct.exi.api.sax.EXIResult in project arctic-sea by 52North.

the class EXIResponseWriter method write.

@Override
public void write(EXIObject<XmlObject> exiObject, OutputStream out, ResponseProxy responseProxy) throws IOException, EncodingException {
    byte[] bytes = getBytes(exiObject);
    try (InputStream is = new ByteArrayInputStream(bytes)) {
        EXIResult result = new EXIResult(this.exiFactory.get());
        result.setOutputStream(out);
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setContentHandler(result.getHandler());
        xmlReader.parse(new InputSource(is));
    } catch (EXIException | SAXException e) {
        throw new EncodingException(e);
    }
}
Also used : EXIResult(com.siemens.ct.exi.api.sax.EXIResult) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) EncodingException(org.n52.svalbard.encode.exception.EncodingException) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EXIException(com.siemens.ct.exi.exceptions.EXIException) XMLReader(org.xml.sax.XMLReader) SAXException(org.xml.sax.SAXException)

Aggregations

EXIResult (com.siemens.ct.exi.api.sax.EXIResult)2 InputStream (java.io.InputStream)2 InputSource (org.xml.sax.InputSource)2 XMLReader (org.xml.sax.XMLReader)2 EXIException (com.siemens.ct.exi.exceptions.EXIException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 OutputStream (java.io.OutputStream)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 SAXException (org.xml.sax.SAXException)1