gpt4 book ai didi

org.opendaylight.controller.config.util.xml.XmlUtil.newDocument()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 01:29:05 26 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.controller.config.util.xml.XmlUtil.newDocument()方法的一些代码示例,展示了XmlUtil.newDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtil.newDocument()方法的具体详情如下:
包路径:org.opendaylight.controller.config.util.xml.XmlUtil
类名称:XmlUtil
方法名:newDocument

XmlUtil.newDocument介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.controller/config-util

public static Document createDocumentCopy(final Document original) {
    final Document copiedDocument = newDocument();
    final Node copiedRoot = copiedDocument.importNode(original.getDocumentElement(), true);
    copiedDocument.appendChild(copiedRoot);
    return copiedDocument;
  }
}

代码示例来源:origin: org.opendaylight.netconf/netconf-netty-util

public static NetconfStartExiMessage create(final EXIOptions exiOptions, final String messageId) {
  final Document doc = XmlUtil.newDocument();
  final Element rpcElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
      XmlNetconfConstants.RPC_KEY);
  rpcElement.setAttributeNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
      XmlNetconfConstants.MESSAGE_ID, messageId);
  // TODO draft http://tools.ietf.org/html/draft-varga-netconf-exi-capability-02#section-3.5.1 has no namespace for start-exi element in xml
  final Element startExiElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0,
      START_EXI);
  addAlignment(exiOptions, doc, startExiElement);
  addFidelity(exiOptions, doc, startExiElement);
  rpcElement.appendChild(startExiElement);
  doc.appendChild(rpcElement);
  return new NetconfStartExiMessage(doc);
}

代码示例来源:origin: org.opendaylight.netconf/netconf-util

private static Document filtered(XmlElement filter, Document originalReplyDocument) throws DocumentedException {
  Document result = XmlUtil.newDocument();
  // even if filter is empty, copy /rpc/data
  Element rpcReply = originalReplyDocument.getDocumentElement();
  Node rpcReplyDst = result.importNode(rpcReply, false);
  result.appendChild(rpcReplyDst);
  XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
  Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
  rpcReplyDst.appendChild(dataDst);
  addSubtree(filter, dataSrc, XmlElement.fromDomElement(dataDst));
  return result;
}

代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector

@Override
public Document handle(final Document requestMessage,
            final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
  final XmlElement requestElement = getRequestElementWithCheck(requestMessage);
  final Document document = XmlUtil.newDocument();
  final XmlElement operationElement = requestElement.getOnlyChildElement();
  final Map<String, Attr> attributes = requestElement.getAttributes();
  final Element response = handle(document, operationElement, subsequentOperation);
  final Element rpcReply = XmlUtil.createElement(document, XmlMappingConstants.RPC_REPLY_KEY, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
  if(XmlElement.fromDomElement(response).hasNamespace()) {
    rpcReply.appendChild(response);
  } else {
    final NodeList list = response.getChildNodes();
    if (list.getLength() == 0) {
      rpcReply.appendChild(response);
    } else {
      while (list.getLength() != 0) {
        rpcReply.appendChild(list.item(0));
      }
    }
  }
  for (Attr attribute : attributes.values()) {
    rpcReply.setAttributeNode((Attr) document.importNode(attribute, true));
  }
  document.appendChild(rpcReply);
  return document;
}

代码示例来源:origin: org.opendaylight.netconf/netconf-util

@Override
public Document handle(final Document requestMessage,
    final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
  XmlElement requestElement = getRequestElementWithCheck(requestMessage);
  Document document = XmlUtil.newDocument();
  XmlElement operationElement = requestElement.getOnlyChildElement();
  Map<String, Attr> attributes = requestElement.getAttributes();
  Element response = handle(document, operationElement, subsequentOperation);
  Element rpcReply = XmlUtil.createElement(document, XmlMappingConstants.RPC_REPLY_KEY, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
  if(XmlElement.fromDomElement(response).hasNamespace()) {
    rpcReply.appendChild(response);
  } else {
    Element responseNS = XmlUtil.createElement(document, response.getNodeName(), Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
    NodeList list = response.getChildNodes();
    while(list.getLength()!=0) {
      responseNS.appendChild(list.item(0));
    }
    rpcReply.appendChild(responseNS);
  }
  for (Attr attribute : attributes.values()) {
    rpcReply.setAttributeNode((Attr) document.importNode(attribute, true));
  }
  document.appendChild(rpcReply);
  return document;
}

代码示例来源:origin: org.opendaylight.netconf/netconf-util

private static Document filteredNotification(XmlElement filter, Document originalNotification) throws DocumentedException {
  Document result = XmlUtil.newDocument();
  XmlElement dataSrc = XmlElement.fromDomDocument(originalNotification);
  Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
  for (XmlElement filterChild : filter.getChildElements()) {
    addSubtree2(filterChild, dataSrc.getOnlyChildElement(), XmlElement.fromDomElement(dataDst));
  }
  if(dataDst.getFirstChild() != null) {
    result.appendChild(dataDst.getFirstChild());
    return result;
  } else {
    return null;
  }
}

代码示例来源:origin: org.opendaylight.netconf/messagebus-netconf

private AnyXmlNode encapsulate(final DOMNotification body) {
  // FIXME: Introduce something like YangModeledAnyXmlNode in Yangtools
  final Document doc = XmlUtil.newDocument();
  final Optional<String> namespace = Optional.of(PAYLOAD_ARG.getNodeType().getNamespace().toString());
  final Element element = XmlUtil.createElement(doc, "payload", namespace);
  final DOMResult result = new DOMResult(element);
  final SchemaContext context = mount.getSchemaContext();
  final SchemaPath schemaPath = body.getType();
  try {
    NetconfUtil.writeNormalizedNode(body.getBody(), result, schemaPath, context);
    return Builders.anyXmlBuilder().withNodeIdentifier(PAYLOAD_ARG).withValue(new DOMSource(element)).build();
  } catch (IOException | XMLStreamException e) {
    LOG.error("Unable to encapsulate notification.", e);
    throw Throwables.propagate(e);
  }
}

代码示例来源:origin: org.opendaylight.controller/blueprint

ValidationException, ConflictingVersionException {
Document document = XmlUtil.newDocument();
Element dataElement = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
Element modulesElement = XmlUtil.createElement(document, XmlMappingConstants.MODULES_KEY,

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com