Interface XMLOutput

All Known Implementing Classes:
Dom4JXMLOutput, OutputStreamXMLOutput

@CleanupObligation public interface XMLOutput
Interface to generate an XML document in some form. E.g., writing it to a stream, generating SAX events, etc.
Author:
David Hovemeyer
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAttribute(String name, String value)
    Add an attribute to a started tag.
    void
    Begin the XML document.
    void
    closeTag(String tagName)
    Close tag with given name.
    void
    Finish writing XML output, closing any underlying resources (such as output streams).
    void
    Open and close tag with given name.
    void
    openCloseTag(String tagName, XMLAttributeList attributeList)
    Open and close tag with given name and given attributes.
    void
    openTag(String tagName)
    Open a tag with given name.
    void
    openTag(String tagName, XMLAttributeList attributeList)
    Open a tag with given name and given attributes.
    void
    startTag(String tagName)
    Start a tag, with the intention of adding attributes.
    void
    stopTag(boolean close)
    End a started tag.
    void
    Write a CDATA section to the XML document.
    void
    Write text to the XML document.
  • Method Details

    • beginDocument

      void beginDocument() throws IOException
      Begin the XML document.
      Throws:
      IOException
    • openTag

      void openTag(String tagName) throws IOException
      Open a tag with given name.
      Parameters:
      tagName - the tag name
      Throws:
      IOException
    • openTag

      void openTag(String tagName, XMLAttributeList attributeList) throws IOException
      Open a tag with given name and given attributes.
      Parameters:
      tagName - the tag name
      attributeList - the attributes
      Throws:
      IOException
    • startTag

      void startTag(String tagName) throws IOException
      Start a tag, with the intention of adding attributes. Must be followed by stopTag after zero or more addAttribute calls.
      Parameters:
      tagName - the tag name
      Throws:
      IOException
    • addAttribute

      void addAttribute(String name, String value) throws IOException
      Add an attribute to a started tag. Must follow a call to startTag.
      Parameters:
      name - the attribute name.
      value - the attribute value, unescaped.
      Throws:
      IOException
    • stopTag

      void stopTag(boolean close) throws IOException
      End a started tag. Must follow a call to startTag.
      Parameters:
      close - true if the element has no content.
      Throws:
      IOException
    • openCloseTag

      void openCloseTag(String tagName) throws IOException
      Open and close tag with given name.
      Parameters:
      tagName - the tag name
      Throws:
      IOException
    • openCloseTag

      void openCloseTag(String tagName, XMLAttributeList attributeList) throws IOException
      Open and close tag with given name and given attributes.
      Parameters:
      tagName - the tag name
      attributeList - the attributes
      Throws:
      IOException
    • closeTag

      void closeTag(String tagName) throws IOException
      Close tag with given name.
      Parameters:
      tagName - the tag name
      Throws:
      IOException
    • writeText

      void writeText(String text) throws IOException
      Write text to the XML document. XML metacharacters are automatically escaped.
      Parameters:
      text - the text to write
      Throws:
      IOException
    • writeCDATA

      void writeCDATA(String cdata) throws IOException
      Write a CDATA section to the XML document. The characters are not escaped in any way.
      Parameters:
      cdata - the character data to write
      Throws:
      IOException
    • finish

      @DischargesObligation void finish() throws IOException
      Finish writing XML output, closing any underlying resources (such as output streams). A call to this method should always be made, even if one of the XML-generation methods throws an exception. Therefore, a call to this method should be performed in a finally block.
      Throws:
      IOException