Package org.w3c.dom

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


            case Node.ENTITY_REFERENCE_NODE: {
                node = factory.createEntityReference(place.getNodeName());
                break;
            }
            case Node.PROCESSING_INSTRUCTION_NODE: {
                node = factory.createProcessingInstruction(place.getNodeName(),
                        place.getNodeValue());
                break;
            }
            case Node.TEXT_NODE: {
                node = factory.createTextNode(place.getNodeValue());
View Full Code Here


        case Node.ENTITY_REFERENCE_NODE:
            copy = doc.createEntityReference(child.getNodeName());
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            final ProcessingInstruction pi = (ProcessingInstruction)child;
            copy = doc.createProcessingInstruction(pi.getTarget(), pi.getData());
            break;
        case Node.TEXT_NODE:
            copy = doc.createTextNode(((Text) child).getData());
            break;
        default:
View Full Code Here

            case XMLStreamConstants.CDATA:
                parent.appendChild(doc.createCDATASection(reader.getText()));

                break;
            case XMLStreamConstants.PROCESSING_INSTRUCTION:
                parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));

                break;
            case XMLStreamConstants.ENTITY_REFERENCE:
                parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
View Full Code Here

            case XMLStreamConstants.PROCESSING_INSTRUCTION:
                parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));

                break;
            case XMLStreamConstants.ENTITY_REFERENCE:
                parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));

                break;
            default:
                break;
            }
View Full Code Here

                case Node.ENTITY_REFERENCE_NODE: {
                    node = factory.createEntityReference(place.getNodeName());
                    break;
                }
                case Node.PROCESSING_INSTRUCTION_NODE: {
                    node = factory.createProcessingInstruction(place.getNodeName(),
                                                               place.getNodeValue());
                    break;
                }
                case Node.TEXT_NODE: {
                    node = factory.createTextNode(place.getNodeValue());
View Full Code Here

        root.appendChild(createResultsElement((ResultSet) queryResult,
            doc));
      }
      DOMSource source = new DOMSource(doc);
      if (applyStyle) {
        ProcessingInstruction instruction = doc
            .createProcessingInstruction("xml-stylesheet",
                "type=\"text/xsl\" href=\"" + styleSheetUri + "\"");
        doc.insertBefore(instruction, root);
        if (applyServerSide) {
          return applyStyleServerSide(source, styleSheetUri);
View Full Code Here

    assertEquals("<svg:span><svg:br /></svg:span>", rendered);
  }

  public final void testProcessingInstructions() {
    Document doc = DomParser.makeDocument(null, null);
    ProcessingInstruction pi = doc.createProcessingInstruction("foo", "bar");
    assertEquals("<?foo bar?>", Nodes.render(pi, MarkupRenderMode.XML));
  }

  public final void testDocumentType() throws ParseException {
    String[] docTypes = {
View Full Code Here

           { "xml", "foo" }, { "XmL", "foo" },
           { "foo?><script>alert(1)</script>", "<?bar baz" },
           { "ok", "foo?><script>alert(1)</script><?foo bar" },
         }) {
      try {
        ProcessingInstruction pi = doc.createProcessingInstruction(
            badPi[0], badPi[1]);
        Nodes.render(pi, MarkupRenderMode.XML);
      } catch (UncheckedUnrenderableException ex) {
        continue// OK
      } catch (DOMException ex) {
View Full Code Here

    }
  }

  public final void testProcessingInstructionInHtml() {
    Document doc = DomParser.makeDocument(null, null);
    ProcessingInstruction pi = doc.createProcessingInstruction(
        "foo", "<script>alert(1)</script>");
    Element el = doc.createElementNS(Namespaces.HTML_NAMESPACE_URI, "div");
    el.appendChild(pi);
    assertEquals(
        "<div><?foo <script>alert(1)</script>?></div>",
View Full Code Here

        DOMTestUtil.execute(new DOMTestUtil.Test() {
            public void execute(DocumentBuilderFactory dbf) throws Exception {
                Document doc = dbf.newDocumentBuilder().newDocument();
               
                doc.appendChild(doc.createComment("some comment"));
                doc.appendChild(doc.createProcessingInstruction("pi", "data"));
               
                // Document Object Model (DOM) Level 3 Core Specification, section 1.1.1
                // says that text nodes are not allowed as children of a document.
                try {
                    doc.appendChild(doc.createTextNode("    "));
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.