Examples of OutputFormat


Examples of org.apache.xml.serialize.OutputFormat

        addNode(tempDocument, tempRootElement, tempRootNode);
        tempDocument.appendChild(tempRootElement);
       
        // write the XML Document
        File tempFile = new File(inFileName);
        OutputFormat    format  = new OutputFormat( tempDocument );   //Serialize DOM
        format.setIndenting(true);
        format.setLineSeparator("\n");
        FileWriter  fout = new FileWriter(tempFile);        //Writer will be a String
        XMLSerializer    serial = new XMLSerializer( fout, format );
        serial.asDOMSerializer();                            // As a DOM Serializer
        serial.serialize( tempDocument.getDocumentElement() );
        fout.close();
View Full Code Here

Examples of org.apache.xml.serialize.OutputFormat

            OutputStream out = outputContext.getOutputStream();
            if (out != null && exists()) {
                if (isMultiple()) {
                    Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                    doc.appendChild(getProperty(JCR_VALUES).toXml(doc));
                    OutputFormat format = new OutputFormat("xml", "UTF-8", false);
                    XMLSerializer serializer = new XMLSerializer(out, format);
                    serializer.setNamespaces(true);
                    serializer.asDOMSerializer().serialize(doc);
                } else {
                    in = ((Property)item).getStream();
View Full Code Here

Examples of org.dom4j.io.OutputFormat

        this.writer = writer;
    }

    public void doWork() {
        try {
            XMLWriter output = new XMLWriter(writer, new OutputFormat("  ", true));
            output.write(createDocument());
            output.close();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

Examples of org.dom4j.io.OutputFormat

            settingsElement.addElement(entry.getKey()).
                    addAttribute("class", clazz.getName()).
                    setText(w.toString(entry.getValue()));
        }

        XMLWriter output = new XMLWriter(new FileOutputStream(xmlFile), new OutputFormat("  ", true));
        output.write(document);
        output.close();
    }
View Full Code Here

Examples of org.dom4j.io.OutputFormat

    return (root != null) ? root.getStringValue() : "";
  }

  public String asXML() {
    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, format);
      writer.write(this);
View Full Code Here

Examples of org.dom4j.io.OutputFormat

    }
  }

  @Override
  public void write(Writer out) throws IOException {
    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    XMLWriter writer = new XMLWriter(out, format);
    writer.write(this);
  }
View Full Code Here

Examples of org.dom4j.io.OutputFormat

  }

  public String asXML() {
    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, new OutputFormat());

      writer.write(this);
      writer.flush();

      return out.toString();
View Full Code Here

Examples of org.dom4j.io.OutputFormat

    }
  }

  @Override
  public void write(Writer out) throws IOException {
    XMLWriter writer = new XMLWriter(out, new OutputFormat());
    writer.write(this);
  }
View Full Code Here

Examples of org.dom4j.io.OutputFormat

   *            编码方式.
   * @return 格式化以后的XML字符串.如果输入为null或空字符串,则不做任何处理.
   */
  public static String getPrettyString(Document doc, String encoding) {
    StringWriter writer = new StringWriter();
    OutputFormat format = OutputFormat.createPrettyPrint();
    if (encoding == null || "".equals(encoding.trim())) {
      encoding = "GBK";
    }
    format.setEncoding(encoding);
    XMLWriter xmlwriter = new XMLWriter(writer, format);

    try {
      xmlwriter.write(doc);
    } catch (IOException e) {
View Full Code Here

Examples of org.dom4j.io.OutputFormat

                if (pwd != null && pwd.length() > 0) {
                    node.addAttribute("password", pwd);
                }
            }
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(selectedFile));
            OutputFormat format = OutputFormat.createPrettyPrint();
            format.setEncoding("UTF-8");
            XMLWriter xmlWriter = new XMLWriter(bos, format);
            xmlWriter.write(document);
            xmlWriter.flush();
            xmlWriter.close();
            LOG.info(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "File xml saved."));
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.