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
}
}
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);
}
}
Aggregations