public static DataContainerChild<?, ?> toFilterStructure(final YangInstanceIdentifier identifier, final SchemaContext ctx) { final NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, DOMSource, AnyXmlNode> anyXmlBuilder = Builders.anyXmlBuilder().withNodeIdentifier(toId(NETCONF_FILTER_QNAME)); anyXmlBuilder.withAttributes(Collections.singletonMap(NETCONF_TYPE_QNAME, SUBTREE)); final NormalizedNode<?, ?> filterContent = ImmutableNodes.fromInstanceId(ctx, identifier); final Element element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_FILTER_QNAME.getLocalName(), Optional.of(NETCONF_FILTER_QNAME.getNamespace().toString())); element.setAttributeNS(NETCONF_FILTER_QNAME.getNamespace().toString(), NETCONF_TYPE_QNAME.getLocalName(), "subtree"); try { writeNormalizedNode(filterContent, new DOMResult(element), SchemaPath.ROOT, ctx); } catch (IOException | XMLStreamException e) { throw new IllegalStateException("Unable to serialize filter element for path " + identifier, e); } anyXmlBuilder.withValue(new DOMSource(element)); return anyXmlBuilder.build(); }