Exemplo n.º 1
0
  /**
   * 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();
      }
    }
  }
Exemplo n.º 2
0
  protected void writeComment(String text) throws IOException {
    if (format.isNewlines()) {
      println();
      indent();
    }

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

    lastOutputNodeType = Node.COMMENT_NODE;
  }