Class BaseMarkupSerializer

  • All Implemented Interfaces:
    DOMSerializer, Serializer, ContentHandler, DocumentHandler, DTDHandler, DeclHandler, LexicalHandler
    Direct Known Subclasses:
    XMLSerializer

    @Deprecated(since="2021-09-01")
    public abstract class BaseMarkupSerializer
    extends Object
    implements ContentHandler, DocumentHandler, LexicalHandler, DTDHandler, DeclHandler, DOMSerializer, Serializer
    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.
    Base class for a serializer supporting both DOM and SAX pretty serializing of XML/HTML/XHTML documents. Derives classes perform the method-specific serializing, this class provides the common serializing mechanisms.

    The serializer must be initialized with the proper writer and output format before it can be used by calling setOutputCharStream(java.io.Writer) or setOutputByteStream(java.io.OutputStream) for the writer and setOutputFormat(org.apache.jackrabbit.vault.util.xml.serialize.OutputFormat) for the output format.

    The serializer can be reused any number of times, but cannot be used concurrently by two threads.

    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. DOM serializing is done by calling serialize(Document) and SAX serializing is done by firing SAX events and using the serializer as a document handler. This also applies to derived class.

    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.

    When indenting, the serializer is capable of detecting seemingly element content, and serializing these elements indented on separate lines. An element is serialized indented when it is the first or last child of an element, or immediate following or preceding another element.

    See Also:
    Serializer, LSSerializer