Пример #1
0
  /**
   * Writes the given {@link Comment}.
   *
   * @param comment <code>Comment</code> to output.
   * @throws IOException DOCUMENT ME!
   */
  public void write(Comment comment) throws IOException {
    writeComment(comment.getText());

    if (autoFlush) {
      flush();
    }
  }
Пример #2
0
  protected void writeNode(Node node) throws IOException {
    int nodeType = node.getNodeType();

    switch (nodeType) {
      case Node.ELEMENT_NODE:
        writeElement((Element) node);

        break;

      case Node.ATTRIBUTE_NODE:
        writeAttribute((Attribute) node);

        break;

      case Node.TEXT_NODE:
        writeNodeText(node);

        // write((Text) node);
        break;

      case Node.CDATA_SECTION_NODE:
        writeCDATA(node.getText());

        break;

      case Node.ENTITY_REFERENCE_NODE:
        writeEntity((Entity) node);

        break;

      case Node.PROCESSING_INSTRUCTION_NODE:
        writeProcessingInstruction((ProcessingInstruction) node);

        break;

      case Node.COMMENT_NODE:
        writeComment(node.getText());

        break;

      case Node.DOCUMENT_NODE:
        write((Document) node);

        break;

      case Node.DOCUMENT_TYPE_NODE:
        writeDocType((DocumentType) node);

        break;

      case Node.NAMESPACE_NODE:

        // Will be output with attributes
        // write((Namespace) node);
        break;

      default:
        throw new IOException("Invalid node type: " + node);
    }
  }
Пример #3
0
  public void comment(char[] ch, int start, int length) throws SAXException {
    if (showCommentsInDTDs || !inDTD) {
      try {
        charsAdded = false;
        writeComment(new String(ch, start, length));
      } catch (IOException e) {
        handleException(e);
      }
    }

    if (lexicalHandler != null) {
      lexicalHandler.comment(ch, start, length);
    }
  }