org.w3c.dom.Element.cloneNode()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(214)

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

Element.cloneNode介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

private static Element fixupAttrs(Element root) { // #140905
  // #6529766/#6531160: some versions of JAXP reject attributes set using setAttribute
  // (rather than setAttributeNS) even though the schema calls for no-NS attrs!
  // JDK 5 is fine; JDK 6 broken; JDK 6u2+ fixed
  // #146081: xml:base attributes mess up validation too.
  Element copy = (Element) root.cloneNode(true);
  fixupAttrsSingle(copy);
  NodeList nl = copy.getElementsByTagName("*"); // NOI18N
  for (int i = 0; i < nl.getLength(); i++) {
    fixupAttrsSingle((Element) nl.item(i));
  }
  return copy;
}
private static void fixupAttrsSingle(Element e) throws DOMException {

代码示例来源:origin: apache/nifi

public static Map<ControllerServiceNode, Element> loadControllerServices(final List<Element> serviceElements, final FlowController controller,
                                     final ProcessGroup parentGroup, final StringEncryptor encryptor) {
  final Map<ControllerServiceNode, Element> nodeMap = new HashMap<>();
  for (final Element serviceElement : serviceElements) {
    final ControllerServiceNode serviceNode = createControllerService(controller, serviceElement, encryptor);
    if (parentGroup == null) {
      controller.getFlowManager().addRootControllerService(serviceNode);
    } else {
      parentGroup.addControllerService(serviceNode);
    }
    // We need to clone the node because it will be used in a separate thread below, and
    // Element is not thread-safe.
    nodeMap.put(serviceNode, (Element) serviceElement.cloneNode(true));
  }
  for (final Map.Entry<ControllerServiceNode, Element> entry : nodeMap.entrySet()) {
    configureControllerService(entry.getKey(), entry.getValue(), encryptor);
  }
  return nodeMap;
}

代码示例来源:origin: marytts/marytts

Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
prosody.setAttribute("contour", contourValue);
prosody.appendChild(tokenElement.cloneNode(true));
tokenAncestor.insertBefore(prosody, tokenElement);
Element nextTokenElement = (Element) tw.nextNode();

代码示例来源:origin: marytts/marytts

Element prosody = MaryXML.createElement(doc, MaryXML.PROSODY);
prosody.setAttribute("contour", contourValue);
prosody.appendChild(tokenElement.cloneNode(true));
tokenAncestor.insertBefore(prosody, tokenElement);
Element nextTokenElement = (Element) tw.nextNode();

代码示例来源:origin: de.sfb876/streams-runtime

/**
 * Extract the config {@link org.w3c.dom.Element} as a new
 * {@link org.w3c.dom.Document}.
 *
 * @param node
 * @return
 * @throws ParserConfigurationException
 */
public static final Element createConfigDocument(Element node) throws ParserConfigurationException {
  Element clone = (Element) node.cloneNode(true);
  return clone;
}

代码示例来源:origin: org.graniteds/granite-server

/**
 * Constructs a new XMap instance.
 * 
 * @param root the root element (may be null).
 * @param clone should we clone the root element (prevent original node modification).
 */
protected XMap(XMLUtil xmlUtil, Element root, boolean clone) {
  this.xmlUtil = xmlUtil;
  this.root = (clone && root != null ? (Element)root.cloneNode(true) : root);
  
}

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

public boolean visit(String tag, Element element) throws SpecParserException {
 elements.put(tag, element.cloneNode(true));
 return true;
}
public void apply(ModulePrefs moduleprefs) {

代码示例来源:origin: org.apache.shindig/shindig-gadgets

public boolean visit(String tag, Element element) throws SpecParserException {
 elements.put(tag, element.cloneNode(true));
 return true;
}
public void apply(ModulePrefs moduleprefs) {

代码示例来源:origin: opendedup/sdfs

public static Element toXMLElement(String fileName) throws Exception {
  File file = new File(fileName);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  Document doc = db.parse(file);
  doc.getDocumentElement().normalize();
  Element root = doc.getDocumentElement();
  return (Element) root.cloneNode(true);
}

代码示例来源:origin: SAMLRaider/SAMLRaider

public void applyXSW5(Document document){
  Element evilAssertion = (Element) document.getElementsByTagNameNS("*", "Assertion").item(0);
  Element assertion = (Element) evilAssertion.cloneNode(true);
  Element copiedSignature = (Element) assertion.getElementsByTagNameNS("*", "Signature").item(0);
  assertion.removeChild(copiedSignature);
  document.getDocumentElement().appendChild(assertion);
  evilAssertion.setAttribute("ID", "_evil_assertion_ID");
}

代码示例来源:origin: SAMLRaider/SAMLRaider

public void applyXSW1(Document document){
  Element response = (Element) document.getElementsByTagNameNS("*", "Response").item(0);
  Element clonedResponse = (Element) response.cloneNode(true);
  Element clonedSignature = (Element) clonedResponse.getElementsByTagNameNS("*", "Signature").item(0);
  clonedResponse.removeChild(clonedSignature);
  Element signature = (Element) response.getElementsByTagNameNS("*", "Signature").item(0);
  signature.appendChild(clonedResponse);
  response.setAttribute("ID", "_evil_response_ID");
}

代码示例来源:origin: SAMLRaider/SAMLRaider

public void applyXSW2(Document document){
  Element response = (Element) document.getElementsByTagNameNS("*", "Response").item(0);
  Element clonedResponse = (Element) response.cloneNode(true);
  Element clonedSignature = (Element) clonedResponse.getElementsByTagNameNS("*", "Signature").item(0);
  clonedResponse.removeChild(clonedSignature);
  Element signature = (Element) response.getElementsByTagNameNS("*", "Signature").item(0);
  response.insertBefore(clonedResponse, signature);
  response.setAttribute("ID", "_evil_response_ID");
}

代码示例来源:origin: SAMLRaider/SAMLRaider

public void applyXSW7(Document document){
  Element assertion = (Element) document.getElementsByTagNameNS("*", "Assertion").item(0);
  Element extensions = document.createElement("Extensions");
  document.getDocumentElement().insertBefore(extensions, assertion);
  Element evilAssertion = (Element) assertion.cloneNode(true);
  Element copiedSignature = (Element) evilAssertion.getElementsByTagNameNS("*", "Signature").item(0);
  evilAssertion.removeChild(copiedSignature);
  extensions.appendChild(evilAssertion);
}

代码示例来源:origin: espertechinc/esper

private static Element cloneMove(Element cloned, String allowedCSV, Element target) {
  Element clone = (Element) cloned.cloneNode(true);
  Element appended = (Element) target.appendChild(clone);
  removeNodesBut(allowedCSV, appended);
  return clone;
}

代码示例来源:origin: org.opensingular/singular-commons

/**
 * @see org.w3c.dom.Node#cloneNode(boolean)
 */
public Node cloneNode(boolean arg0) {
  return getCurrentInternal().cloneNode(arg0);
}

代码示例来源:origin: org.opensingular/form-core

/**
 * @see org.w3c.dom.Node#cloneNode(boolean)
 */
@Override
public Node cloneNode(boolean arg0) {
  return original.get().cloneNode(arg0);
}

代码示例来源:origin: opendedup/sdfs

public static Element getCurrentSeqNum() throws ParserConfigurationException {
  long sqnum = seqnum.get();
  SDFSLogger.getLog().debug("getting sequence number " + sqnum);
  Document doc = XMLUtils.getXMLDoc("seq");
  /*
   * if (SDFSLogger.isDebug()) SDFSLogger.getLog().debug(this.toString());
   */
  Element root = doc.getDocumentElement();
  root.setAttribute("num",Long.toString(sqnum));
  return (Element) root.cloneNode(true);
}

代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite

protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS("urn:test", "p:elem");
    Element clone = (Element)element.cloneNode(true);
    assertEquals("urn:test", clone.getNamespaceURI());
    assertEquals("p", clone.getPrefix());
    assertEquals("elem", clone.getLocalName());
    assertSame(document, clone.getOwnerDocument());
  }
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

private String elementToXmlString(Element element) {
  //	TODO	My goodness ECMA is complicated (see 10.2.1).  We'll try this first.
  Element copy = (Element)element.cloneNode(true);
  if (prettyPrint) {
    beautifyElement(copy, 0);
  }
  return toString(copy);
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-wsdlgen

public Definition cloneDefinition(WSDLFactory factory, Definition definition) throws WSDLException {
  Element root = definition.getDocumentationElement();
  root = (Element)root.cloneNode(true);
  WSDLReader reader = factory.newWSDLReader();
  return reader.readWSDL(definition.getDocumentBaseURI(), root);
}

相关文章

微信公众号

最新文章

更多