Interface Document

All Superinterfaces:
Container

public interface Document extends Container
A Container representing a document node.

If the document is constrained to be well-formed then the permitted sequence of events is (COMMENT | PI)* ELEMENT (COMMENT | PI)* CLOSE.

If the document is NOT constrained to be well-formed then the permitted sequence of events is (COMMENT | PI | TEXT | ELEMENT)* CLOSE.

  • Method Details

    • text

      Description copied from interface: Container
      Add text content to the current element node (or, in the case of a non-well-formed document, as a child of the document node).

      Multiple consecutive calls on text() generate a single text node with concatenated content: that is, text("one).text("two") is equivalent to text("onetwo").

      Specified by:
      text in interface Container
      Parameters:
      value - the content of the text node. Supplying a zero-length string or null is permitted, but has no effect.
      Returns:
      the Container to which the method is applied. This is to allow chained method calls, of the form tag.element("a").text("content").close()
      Throws:
      SaxonApiException - if the specified constraints are violated, or if the implementation detects any problems
    • comment

      Document comment(CharSequence value) throws SaxonApiException
      Description copied from interface: Container
      Add a comment node to the current element or document node.

      The method call is allowed in states START_TAG, CONTENT, and NON_TEXT_CONTENT, and it sets the state to CONTENT.

      Specified by:
      comment in interface Container
      Parameters:
      value - the content of the comment node. The value should not contain the string "--"; it is implementation-defined whether this causes an exception, or whether some recovery action is taken such as replacing the string by "- -". If the value is null, no comment node is written.
      Returns:
      the Container to which the method is applied. This is to allow chained method calls, of the form tag.element("a").comment("optional").close()
      Throws:
      SaxonApiException - if the specified constraints are violated, or if the implementation detects any problems
    • processingInstruction

      Document processingInstruction(String name, CharSequence value) throws SaxonApiException
      Description copied from interface: Container
      Add a processing instruction node to the current element or document node.

      The method call is allowed in states START_TAG, CONTENT, and NON_TEXT_CONTENT, and it sets the state to CONTENT.

      Specified by:
      processingInstruction in interface Container
      Parameters:
      name - the name ("target") of the processing instruction. The level of validation applied to the supplied name is implementation-defined. Must not be null.
      value - the content ("data") of the processing instruction node. The value should not contain the string "?>"; it is implementation-defined whether this causes an exception, or whether some recovery action is taken such as replacing the string by "? >". If the value is null, no processing instruction node is written.
      Returns:
      the Container to which the method is applied. This is to allow chained method calls, of the form tag.element("a").processing-instruction("target", "data").close()
      Throws:
      SaxonApiException - if the specified constraints are violated, or if the implementation detects any problems