Package nu.xom

Examples of nu.xom.Document.insertChild()


                            if (child instanceof Element) {
                                doc.setRootElement((Element) child);
                                break;  
                            }
                            else {
                                doc.insertChild(
                                  child, doc.indexOf(element)
                                );
                            }

                        }
View Full Code Here


                        }
                        // epilog
                        Element root = doc.getRootElement();
                        int position = doc.indexOf(root);
                        for (int j=i; j < replacements.size(); j++) {
                            doc.insertChild(
                              replacements.get(j), position+1+j-i
                            );                            
                        }
                    }
                }
View Full Code Here

    public void testCanonicalizeCommentsInPrologAndEpilog() throws IOException {
       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new Comment("comment 1"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new Comment("comment 4"));
       
        String expected = "<!--comment 1-->\n<!--comment 2-->\n\n<!--comment 3-->\n<!--comment 4-->";
View Full Code Here

       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new Comment("comment 1"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new Comment("comment 4"));
       
        String expected = "<!--comment 1-->\n<!--comment 2-->\n\n<!--comment 3-->\n<!--comment 4-->";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

    public void testCanonicalizePrologAndEpilog() throws IOException {
       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new ProcessingInstruction("target", "value"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new ProcessingInstruction("target", "value"));
       
        String expected = "<?target value?>\n<!--comment 2-->\n<doc></doc>\n<!--comment 3-->\n<?target value?>";
View Full Code Here

       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new ProcessingInstruction("target", "value"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new ProcessingInstruction("target", "value"));
       
        String expected = "<?target value?>\n<!--comment 2-->\n<doc></doc>\n<!--comment 3-->\n<?target value?>";
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

   
    public void testNFCInComment() throws IOException {
       
        Element root = new Element("a");
        Document doc = new Document(root);
        doc.insertChild(new Comment("c\u0327hat"), 0); // c with combining cedilla
        Serializer serializer = new Serializer(out);
        serializer.setUnicodeNormalizationFormC(true);
        serializer.write(doc);
        serializer.flush();
        out.close();
View Full Code Here

      response.sendError(code, str);
    } else {
        String serverRoot = Oscar3Props.getInstance().serverRoot;
        if(serverRoot == null || serverRoot.equals("none")) serverRoot = "";
      ProcessingInstruction pi = new ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + serverRoot + "/sciborg.xsl\"");
      responseDoc.insertChild(pi, 0);
      response.setContentType("application/xml");
      new Serializer(response.getOutputStream()).write(responseDoc);     
    }
  }
   
View Full Code Here

   */
  private void saveFile(String filename, Resource resource) throws IOException {
    FileOutputStream os = null;
    try {
      Document doc = new Document(resource.getXOMElementCopy());
      doc.insertChild(new Comment(" Generated by Escort in DDMSence v" + PropertyReader.getProperty("version")
        + " "), 0);
      File outputFile = new File(PropertyReader.getProperty("sample.data"), filename);
      os = new FileOutputStream(outputFile);
      Serializer serializer = new Serializer(os);
      serializer.setIndent(3);
View Full Code Here

        copy.setBaseURI(doc.getBaseURI());
        for (int i = 0; i < doc.getChildCount(); i++) {
            Node child = doc.getChild(i);
            if (child == originalRoot) continue;
            Node node = copy(child);
            copy.insertChild(node, i);
        }
        return copy;
       
    }
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.