com.mapinfo.midev.xml.write

## Interface IXmlWriter

All Superinterfaces:
  AutoCloseable, Closeable, Flushable

    public interface IXmlWriter
    extends Flushable, Closeable

An interface for writing XML.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `close()` Close the writer and the underlying output stream.
`void` `flush()` Flush the writer and force any buffered data to be written.
`String` `getEncoding()` Get the encoding of the writer.
`String` `getXmlLang()` Get the language of the current element.
`XmlSpace` `getXmlSpace()` Get the space of the current element.
`void` `writeAttributeString(String localName, String value)` Write an attribute with the specified local name and value.
`void` `writeAttributeString(String localName, String ns, String value)` Write an attribute with the specified local name, namespace URI, and value.
`void` `writeAttributeString(String prefix, String localName, String ns, String value)` Write an attribute with the specified prefix, local name, namespace URI, and value.
`void` `writeDocType(String name, String pubid, String sysid, String subset)` Write the doc type for the XML.
`void` `writeElementString(String localName, String ns, String value)` Write a leaf element with the specified local name, namespace URI, and value.
`void` `writeElementString(String prefix, String localName, String ns, String value)` Write a leaf element with the specified prefix, local name, namespace URI, and value.
`void` `writeEndDocument()` Write the end of the document.
`void` `writeEndElement()` Write an element end tag.
`void` `writeNamespacePrefixDefinition(String prefix, String ns)` Define a namespace prefix in the current context.
`void` `writeRaw(String data)` Write raw XML to the stream.
`void` `writeStartDocument()` Write the start of the document.
`void` `writeStartElement(String localName, String ns)` Write an element start tag with the specified local name and namespace URI.
`void` `writeStartElement(String prefix, String localName, String ns)` Write an element start tag with the specifiedprefix, local name, and namespace URI.
`void` `writeString(String text)` Write element content.

### Method Detail

#### close

    void close()
        throws XmlWriterException

Close the writer and the underlying output stream.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `XmlWriterException` - if there is a problem closing the writer or the underlying output stream.

#### flush

    void flush()
        throws XmlWriterException

Flush the writer and force any buffered data to be written.

Specified by:
  `flush` in interface `Flushable`
Throws:
  `XmlWriterException` - if there is a problem flushing the writer.

#### writeStartDocument

    void writeStartDocument()
                     throws XmlWriterException

Write the start of the document.

Throws:
  `XmlWriterException` - if there is a problem writing the start of the document.

#### writeEndDocument

    void writeEndDocument()
                   throws XmlWriterException

Write the end of the document.

Throws:
  `XmlWriterException` - if there is a problem writing the end of the document.

#### writeDocType

    void writeDocType(String name,
                      String pubid,
                      String sysid,
                      String subset)
               throws XmlWriterException

Write the doc type for the XML.

Parameters:
  `name` - The name of the doc type. Must be the same as the root element. May not be null.
  `pubid` - If non-null it also writes "pubid" "sysid" where pubid and sysid are replaced with the value of the given arguments.
  `sysid` - f pubid is null and sysid is non-null it writes SYSTEM "sysid" where sysid is replaced with the value of this argument.
  `subset` - If non-null it writes [subset] where subset is replaced with the value of this argument.
Throws:
  `XmlWriterException` - if there is a problem writing the doc type.

#### writeStartElement

    void writeStartElement(String localName,
                           String ns)
                    throws XmlWriterException

Write an element start tag with the specified local name and namespace URI.

Parameters:
  `localName` - write an element start tag with this local name.
  `ns` - write an element start tag with this namespace URI.
Throws:
  `XmlWriterException` - if there is a problem writing the start tag.

#### writeStartElement

    void writeStartElement(String prefix,
                           String localName,
                           String ns)
                    throws XmlWriterException

Write an element start tag with the specifiedprefix, local name, and namespace URI.

Parameters:
  `prefix` - write an element start tag with this namespace prefix.
  `localName` - write an element start tag with this local name.
  `ns` - write an element start tag with this namespace URI.
Throws:
  `XmlWriterException` - if there is a problem writing the start tag.

#### writeEndElement

    void writeEndElement()
                  throws XmlWriterException

Write an element end tag.

Throws:
  `XmlWriterException` - if there is a problem writing the end tag.

#### writeElementString

    void writeElementString(String localName,
                            String ns,
                            String value)
                     throws XmlWriterException

Write a leaf element with the specified local name, namespace URI, and value.

Parameters:
  `localName` - write a leaf element with this local name.
  `ns` - write a leaf element with this namespace URI.
  `value` - write a leaf element with this value.
Throws:
  `XmlWriterException` - if there is a problem writing the element.

#### writeElementString

    void writeElementString(String prefix,
                            String localName,
                            String ns,
                            String value)
                     throws XmlWriterException

Write a leaf element with the specified prefix, local name, namespace URI, and value.

Parameters:
  `prefix` - write a leaf element with this namespace prefix.
  `localName` - write a leaf element with this local name.
  `ns` - write a leaf element with this namespace URI.
  `value` - write a leaf element with this value.
Throws:
  `XmlWriterException` - if there is a problem writing the element.

#### writeAttributeString

    void writeAttributeString(String localName,
                              String value)
                       throws XmlWriterException

Write an attribute with the specified local name and value.

Parameters:
  `localName` - write an attribute with this local name.
  `value` - write an attribute with this value.
Throws:
  `XmlWriterException` - if there is a problem writing the attribute.

#### writeAttributeString

    void writeAttributeString(String localName,
                              String ns,
                              String value)
                       throws XmlWriterException

Write an attribute with the specified local name, namespace URI, and value.

Parameters:
  `localName` - write an attribute with this local name.
  `ns` - write an attribute with this namespace URI.
  `value` - write an attribute with this value.
Throws:
  `XmlWriterException` - if there is a problem writing the attribute.

#### writeAttributeString

    void writeAttributeString(String prefix,
                              String localName,
                              String ns,
                              String value)
                       throws XmlWriterException

Write an attribute with the specified prefix, local name, namespace URI, and value.

Parameters:
  `prefix` - write an attribute with this namespace prefix.
  `localName` - write an attribute with this local name.
  `ns` - write an attribute with this namespace URI.
  `value` - write an attribute with this value.
Throws:
  `XmlWriterException` - if there is a problem writing the attribute.

#### writeNamespacePrefixDefinition

    void writeNamespacePrefixDefinition(String prefix,
                                        String ns)
                                 throws XmlWriterException

Define a namespace prefix in the current context.

Parameters:
  `prefix` - The namespace prefix to be defined.
  `ns` - The namespace value for the new prefix definition.
Throws:
  `XmlWriterException` - if there is a problem defining the prefix.

#### writeString

    void writeString(String text)
              throws XmlWriterException

Write element content.

Parameters:
  `text` - The content to be written inside the element.
Throws:
  `XmlWriterException` - if there is an error writing the content or the writer is in an invalid state for writing content.

#### writeRaw

    void writeRaw(String data)
           throws XmlWriterException

Write raw XML to the stream.

Parameters:
  `data` - Write the XML contained in this string to the stream. Must be valid XML.
Throws:
  `XmlWriterException`

#### getXmlSpace

    XmlSpace getXmlSpace()

Get the space of the current element. Note that the space is inherited from the element's ancestors. The space is defined by a "space" attribute in the "http://www.w3.org/XML/1998/namespace" or "http://www.w3.org/2001/XMLSchema" namespace.

Returns:
  The space of the current element.

#### getXmlLang

    String getXmlLang()

Get the language of the current element. Note that the language is inherited from the element's ancestors. The space is defined by a "lang" attribute in the "http://www.w3.org/XML/1998/namespace" or "http://www.w3.org/2001/XMLSchema" namespace.

Returns:
  The language of the current element.

#### getEncoding

    String getEncoding()

Get the encoding of the writer.

Returns:
  The encoding of the writer.