private void writeNormalizedRpc(final ContainerNode normalized, final DOMResult result, final SchemaPath schemaPath, final SchemaContext baseNetconfCtx) throws IOException, XMLStreamException {
final OrderedNormalizedNodeWriter normalizedNodeWriter;
NormalizedNodeStreamWriter normalizedNodeStreamWriter = null;
XMLStreamWriter writer = null;
try {
writer = NetconfMessageTransformUtil.XML_FACTORY.createXMLStreamWriter(result);
normalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(writer, baseNetconfCtx, schemaPath);
normalizedNodeWriter = new OrderedNormalizedNodeWriter(normalizedNodeStreamWriter, baseNetconfCtx, schemaPath);
Collection<DataContainerChild<?, ?>> value = (Collection) normalized.getValue();
normalizedNodeWriter.write(value);
normalizedNodeWriter.flush();
} finally {
try {
if(normalizedNodeStreamWriter != null) {
normalizedNodeStreamWriter.close();
}
if(writer != null) {
writer.close();
}
} catch (final Exception e) {
LOG.warn("Unable to close resource properly", e);
}
}
}