예제 #1
0
파일: XMLWriter.java 프로젝트: dom4j/dom4j
  /**
   * This will write the declaration to the given Writer. Assumes XML version 1.0 since we don't
   * directly know.
   *
   * @throws IOException DOCUMENT ME!
   */
  protected void writeDeclaration() throws IOException {
    String encoding = format.getEncoding();

    // Only print of declaration is not suppressed
    if (!format.isSuppressDeclaration()) {
      // Assume 1.0 version
      if (encoding.equals("UTF8")) {
        writer.write("<?xml version=\"1.0\"");

        if (!format.isOmitEncoding()) {
          writer.write(" encoding=\"UTF-8\"");
        }

        writer.write("?>");
      } else {
        writer.write("<?xml version=\"1.0\"");

        if (!format.isOmitEncoding()) {
          writer.write(" encoding=\"" + encoding + "\"");
        }

        writer.write("?>");
      }

      if (format.isNewLineAfterDeclaration()) {
        println();
      }
    }
  }
예제 #2
0
파일: XMLWriter.java 프로젝트: dom4j/dom4j
  protected void writeComment(String text) throws IOException {
    if (format.isNewlines()) {
      println();
      indent();
    }

    writer.write("<!--");
    writer.write(text);
    writer.write("-->");

    lastOutputNodeType = Node.COMMENT_NODE;
  }