Class XMLSerializer

  • All Implemented Interfaces:
    DOMSerializer, Serializer, ContentHandler, DocumentHandler, DTDHandler, DeclHandler, LexicalHandler

    @Deprecated(since="2021-09-01")
    public class XMLSerializer
    extends BaseMarkupSerializer
    Deprecated.
    Util Classes related to Xerces are removed in subsequent releases causing a major version change. As these utils are for internal use in Filevault the API is getting deprecated from public API surface.
    ASF Note: This class and dependencies were copied from the sun jdk1.5 source base. The original serializer is extended by a new OutputFormat setting that allows to break the line for each attribute. additionally, all attribute names are sorted alphabetically. Some Features were removed to limit the number of dependent classes:
    • dom filter support
    • all text nodes as CDATA feature
    • skip attribute default values feature
    • entity node reference feature

    Implements an XML serializer supporting both DOM and SAX pretty serializing. For usage instructions see Serializer.

    If an output stream is used, the encoding is taken from the output format (defaults to UTF-8). If a writer is used, make sure the writer uses the same encoding (if applies) as specified in the output format.

    The serializer supports both DOM and SAX. SAX serializing is done by firing SAX events and using the serializer as a document handler. DOM serializing is done by calling BaseMarkupSerializer.serialize(Document) or by using DOM Level 3

    If an I/O exception occurs while serializing, the serializer will not throw an exception directly, but only throw it at the end of serializing (either DOM or SAX's DocumentHandler.endDocument().

    For elements that are not specified as whitespace preserving, the serializer will potentially break long text lines at space boundaries, indent lines, and serialize elements on separate lines. Line terminators will be regarded as spaces, and spaces at beginning of line will be stripped.

    See Also:
    Serializer