+ private static Optional<? extends NormalizedNode<?, ?>> findSchemasNode(final NormalizedNode<?, ?> result,
+ final SchemaContext schemaContext) {
+ if (result == null) {
+ return Optional.empty();
+ }
+ final Optional<DataContainerChild<?, ?>> rpcResultOpt = ((ContainerNode)result).getChild(NETCONF_DATA_NODEID);
+ if (!rpcResultOpt.isPresent()) {
+ return Optional.empty();
+ }
+
+ final DataContainerChild<?, ?> rpcResult = rpcResultOpt.get();
+ verify(rpcResult instanceof AnyXmlNode, "Unexpected result %s", rpcResult);
+ final NormalizedNode<?, ?> dataNode;
+
+ try {
+ dataNode = NetconfUtil.transformDOMSourceToNormalizedNode(schemaContext,
+ ((AnyXmlNode) rpcResult).getValue()).getResult();
+ } catch (XMLStreamException | URISyntaxException | IOException | SAXException
+ | ParserConfigurationException e) {
+ LOG.warn("Failed to transform {}", rpcResult, e);
+ return Optional.empty();
+ }
+
+ final Optional<DataContainerChild<?, ?>> nStateNode = ((DataContainerNode<?>) dataNode).getChild(
+ toId(NetconfState.QNAME));
+ if (!nStateNode.isPresent()) {
+ return Optional.empty();
+ }
+
+ return ((DataContainerNode<?>) nStateNode.get()).getChild(toId(Schemas.QNAME));
+ }
+
+ public static final class RemoteYangSchema {