Class ToXmlContentHandler

  • All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler

    public class ToXmlContentHandler
    extends DefaultHandler
    Simple XML serializer. This content handler serializes the received SAX events as XML to a given Writer or OutputStream. The serialization assumes that the incoming SAX events are well-formed, i.e. that all elements are properly nested, that element and attribute names are valid and that no invalid XML characters are included. Assuming these preconditions are met, the result will be a well-formed XML stream.

    This serializer does not have any special support for namespaces. For example, namespace prefixes are declared in the resulting XML stream if and only if the corresponding "xmlns" attributes are explicitly included in the Attributes instances passed in startElement(String, String, String, Attributes) calls.

    As a convenience this class inherits the DefaultHandler class instead of just the ContentHandler interface. This makes it easier to pass instances of this class to methods like SAXParser.parse(String, DefaultHandler) that expect a DefaultHandler instance instead of a ContentHandler.