Package org.w3c.dom

Examples of org.w3c.dom.Document.adoptNode()


        cajoledOutput.setAttribute("classes", "g___");
        cajoledOutput.setAttribute("style", "position: relative;");
       
        cajoledOutput.appendChild(doc.adoptNode(html));
        cajoledOutput.appendChild(tameCajaClientApi(doc));
        cajoledOutput.appendChild(doc.adoptNode(script));
       
        if (cajoledCache != null) {
          cajoledCache.addElement(key, cajoledOutput);
        }
        createContainerFor(doc, cajoledOutput);
View Full Code Here


            NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_wsu_Timestamp.getNamespaceURI(), WSSConstants.TAG_wsu_Timestamp.getLocalPart());
            Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());

            Node parentNode = nodeList.item(0).getParentNode();
            Node node = nodeList.item(0).cloneNode(true);
            securedDocument.adoptNode(node);
            parentNode.appendChild(node);

            javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
            transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
        }
View Full Code Here

      childElement.detachNode();

      // child element's owner document might be shared with other elements;
      // we have to create a separate document for returning to our caller
      Document newDocument = DOMUtils.getDocumentBuilder().newDocument();
      Node adoptedElement = newDocument.adoptNode(childElement.domNode);
      newDocument.appendChild(adoptedElement);

      return newDocument;
   }
View Full Code Here

          if (item instanceof Comment) {
            Comment mn = (Comment) item;
            if (mn.getTextContent().contains(
                ONPOSITIVE_COMMENTS_MARK)) {
              for (Element e : toAppend) {
                Node adoptNode = myWebXML.adoptNode(e
                    .cloneNode(true));
                if (a != childNodes2.getLength() - 1) {
                  try {
                    myWebXML.getDocumentElement()
                        .insertBefore(adoptNode,
View Full Code Here

          myWebXML.getDocumentElement().appendChild(
              myWebXML.createComment(ONPOSITIVE_COMMENTS_MARK));
          myWebXML.getDocumentElement().appendChild(
              myWebXML.createTextNode("\n"));
          for (Element e : toAppend) {
            Node adoptNode = myWebXML.adoptNode(e.cloneNode(true));
            myWebXML.getDocumentElement().appendChild(adoptNode);
          }
        }
      }
      StringWriter writer = new StringWriter();
View Full Code Here

        "<!DOCTYPE html>"
    };
    for (String docType : docTypes) {
      Document doc = DomParser.makeDocument(DoctypeMaker.parse(docType), null);
      DocumentFragment html = html(fromString("<html><b>my text</b></html>"));
      doc.appendChild(doc.adoptNode(html));
      MoreAsserts.assertStartsWith(docType,
          Nodes.render(doc.getDoctype(), html, null));
    }
  }
View Full Code Here

      for (Pair<MarkupRenderMode, String> expectedPair : expectedPairs) {
        Document doc = DomParser.makeDocument(
            DoctypeMaker.parse(docType), null);
        Element el = (Element)getOnlyChild(
            html(fromString("<html><b>my text</b></html>")));
        doc.appendChild(doc.adoptNode(el));

        StringBuilder sb = new StringBuilder();
        RenderContext rc = new RenderContext(new Concatenator(sb))
        .withMarkupRenderMode(expectedPair.a);
        Nodes.render(doc.getDoctype(), el, Namespaces.HTML_DEFAULT, rc);
View Full Code Here

  private void assertNoDocType(String docType)
      throws ParseException {
    Document doc = DomParser.makeDocument(DoctypeMaker.parse(docType), null);
    DocumentFragment html = html(fromString("TEST NODE"));
    doc.appendChild(doc.adoptNode(html));
    assertFalse(Nodes.render(doc.getDoctype(), html, null)
        .matches("[<][!]DOCTYPE"));
  }

  private void assertDocType(String expected, String docType)
View Full Code Here

  private void assertDocType(String expected, String docType)
      throws ParseException {
    Document doc = DomParser.makeDocument(DoctypeMaker.parse(docType), null);
    DocumentFragment html = html(fromString("TEST NODE"));
    doc.appendChild(doc.adoptNode(html));
    MoreAsserts.assertStartsWith(expected,
        Nodes.render(doc.getDoctype(), html, null));
  }

  private static Node getOnlyChild(Node parent) {
View Full Code Here

                signedEl.removeAttribute("ID");
                root.removeChild(signatureElement);
            } else {
                Element actualBody = getActualBody(root);
                Document newDoc = DOMUtils.createDocument();
                newDoc.adoptNode(actualBody);
                root = actualBody;
            }
        }
        message.setContent(XMLStreamReader.class,
                           new W3CDOMStreamReader(root));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.