The program flow of an XML write follows this general pattern in a forward-only stream:

  • The write begins with the START-DOCUMENT method and the document prolog is written.
  • To build an element, use the START-ELEMENT method to create the start tag for the desired element type. If you have created a SAX-attributes either to programatically build a list of attributes for the element or to capture a set of attributes during a SAX read operation, you can pass it as an optional parameter to the START-ELEMENT method. (The WRITE-EMPTY-ELEMENT and WRITE-DATA-ELEMENT methods also can take a SAX-attributes object as an optional parameter.)
  • Use the following methods to build the content of the tag:
    • INSERT-ATTRIBUTE( ) method
    • DECLARE-NAMESPACE( ) method
    • WRITE-CDATA( ) method
    • WRITE-CHARACTERS( ) method
    • WRITE-ENTITY-REF( ) method
    • WRITE-FRAGMENT( ) method
  • Use the END-ELEMENT method to provide the closing tag for the named element.
  • Use the other methods to provide other types of XML content:
    • WRITE-EMPTY-ELEMENT( ) method
    • WRITE-DATA-ELEMENT( ) method
    • WRITE-EXTERNAL-DTD( ) method
    • WRITE-PROCESSING-INSTRUCTION( ) method
    • WRITE-COMMENT( ) method
  • Use the END-DOCUMENT method to close the XML document.