import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
-import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.yangtools.rfc7952.data.api.NormalizedMetadata;
public static void writeNormalizedNode(final NormalizedNode normalized, final DOMResult result,
final EffectiveModelContext context, final @Nullable Absolute path) throws IOException, XMLStreamException {
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = NormalizedNodeWriter.forStreamWriter(streamWriter)) {
writer.write(normalized);
writer.flush();
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
XML_NAMESPACE_SETTER.initializeNamespace(xmlWriter);
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = NormalizedMetadataWriter.forStreamWriter(streamWriter)) {
writer.write(normalized, metadata);
writer.flush();
final EffectiveModelContext context, final @Nullable Absolute path) throws IOException, XMLStreamException {
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
XML_NAMESPACE_SETTER.initializeNamespace(xmlWriter);
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = new EmptyListXmlWriter(streamWriter, xmlWriter)) {
final Iterator<PathArgument> it = query.getPathArguments().iterator();
final PathArgument first = it.next();
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
XML_NAMESPACE_SETTER.initializeNamespace(xmlWriter);
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = new EmptyListXmlMetadataWriter(streamWriter, xmlWriter,
streamWriter.getExtensions().getInstance(StreamWriterMetadataExtension.class), metadata)) {
final Iterator<PathArgument> it = query.getPathArguments().iterator();
}
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = new EmptyListXmlWriter(streamWriter, xmlWriter)) {
final Iterator<PathArgument> it = query.getPathArguments().iterator();
final PathArgument first = it.next();
final XMLStreamWriter xmlWriter = XML_FACTORY.createXMLStreamWriter(result);
try {
- try (var streamWriter = newWriter(xmlWriter, context, path);
+ try (var streamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, context, path);
var writer = new EmptyListXmlWriter(streamWriter, xmlWriter)) {
final PathArgument first = rootNode.element();
StreamingContext.fromSchemaAndQNameChecked(context, first.getNodeType())
final DOMSource value) throws XMLStreamException, URISyntaxException, IOException, SAXException {
return transformDOMSourceToNormalizedNode(new EmptyMountPointContext(schemaContext), value);
}
-
- // FIXME: this should not be needed once we have yangtools-10.0.1.
- private static @NonNull NormalizedNodeStreamWriter newWriter(final XMLStreamWriter writer,
- final EffectiveModelContext context, final @Nullable Absolute path) {
- return path == null ? XMLStreamNormalizedNodeStreamWriter.create(writer, context)
- : XMLStreamNormalizedNodeStreamWriter.create(writer, context, path);
- }
}