- /**
- * Write normalized node to {@link DOMResult}.
- *
- * @param normalized
- * data
- * @param context
- * actual schema context
- * @param schemaPath
- * schema path of data
- * @return {@link DOMResult}
- */
- protected DOMResult writeNormalizedNode(final NormalizedNode normalized, final EffectiveModelContext context,
- final SchemaPath schemaPath) throws IOException, XMLStreamException {
- final Document doc = UntrustedXML.newDocumentBuilder().newDocument();
- final DOMResult result = new DOMResult(doc);
- NormalizedNodeWriter normalizedNodeWriter = null;
- NormalizedNodeStreamWriter normalizedNodeStreamWriter = null;
- XMLStreamWriter writer = null;
-
- try {
- writer = OF.createXMLStreamWriter(result);
- normalizedNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(writer, context, schemaPath);
- normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(normalizedNodeStreamWriter);
-
- normalizedNodeWriter.write(normalized);
-
- normalizedNodeWriter.flush();
- } finally {
- if (normalizedNodeWriter != null) {
- normalizedNodeWriter.close();
- }
- if (normalizedNodeStreamWriter != null) {
- normalizedNodeStreamWriter.close();
- }
- if (writer != null) {
- writer.close();
- }
- }
-
- return result;
- }
-