Interface SerializationHandler

All Superinterfaces:
ContentHandler, DeclHandler, DOMSerializer, DTDHandler, ErrorHandler, ExtendedContentHandler, ExtendedLexicalHandler, LexicalHandler, Serializer
All Known Implementing Classes:
AdaptiveResultTreeImpl, EmptySerializer, SerializerBase, SimpleResultTreeImpl, StringValueHandler, ToHTMLSAXHandler, ToHTMLStream, ToSAXHandler, ToStream, ToTextSAXHandler, ToTextStream, ToUnknownStream, ToXMLSAXHandler, ToXMLStream

This interface is the one that a serializer implements. It is a group of other interfaces, such as ExtendedContentHandler, ExtendedLexicalHandler etc. In addition there are other methods, such as reset(). This class is public only because it is used in another package, it is not a public API.
  • Method Details

    • setContentHandler

      void setContentHandler(ContentHandler ch)
      Set the SAX Content handler that the serializer sends its output to. This method only applies to a ToSAXHandler, not to a ToStream serializer.
      See Also:
    • close

      void close()
    • serialize

      void serialize(Node node) throws IOException
      Notify that the serializer should take this DOM node as input to be serialized.
      Specified by:
      serialize in interface DOMSerializer
      Parameters:
      node - the DOM node to be serialized.
      Throws:
      IOException
    • setEscaping

      boolean setEscaping(boolean escape) throws SAXException
      Turns special character escaping on/off. Note that characters will never, even if this option is set to 'true', be escaped within CDATA sections in output XML documents.
      Parameters:
      escape - true if escaping is to be set on.
      Throws:
      SAXException
    • setIndentAmount

      void setIndentAmount(int spaces)
      Set the number of spaces to indent for each indentation level.
      Parameters:
      spaces - the number of spaces to indent for each indentation level.
    • setTransformer

      void setTransformer(Transformer transformer)
      Set the transformer associated with the serializer.
      Parameters:
      transformer - the transformer associated with the serializer.
    • getTransformer

      Transformer getTransformer()
      Get the transformer associated with the serializer.
      Returns:
      Transformer the transformer associated with the serializer.
    • setNamespaceMappings

      void setNamespaceMappings(NamespaceMappings mappings)
      Used only by TransformerSnapshotImpl to restore the serialization to a previous state.
      Parameters:
      mappings - NamespaceMappings
    • flushPending

      void flushPending() throws SAXException
      A SerializationHandler accepts SAX-like events, so it can accumulate attributes or namespace nodes after a startElement().

      If the SerializationHandler has a Writer or OutputStream, a call to this method will flush such accumulated events as a closed start tag for an element.

      If the SerializationHandler wraps a ContentHandler, a call to this method will flush such accumulated events as a SAX (not SAX-like) calls to startPrefixMapping() and startElement().

      If one calls endDocument() then one need not call this method since a call to endDocument() will do what this method does. However, in some circumstances, such as with document fragments, endDocument() is not called and it may be necessary to call this method to flush any pending events.

      For performance reasons this method should not be called very often.

      Throws:
      SAXException
    • setDTDEntityExpansion

      void setDTDEntityExpansion(boolean expand)
      Default behavior is to expand DTD entities, that is the initall default value is true.
      Parameters:
      expand - true if DTD entities are to be expanded, false if they are to be left as DTD entity references.
    • getDoctypePublic

      String getDoctypePublic()
      Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD).
      Returns:
      the public identifier to be used in the DOCTYPE declaration in the output document.
    • getDoctypeSystem

      String getDoctypeSystem()
      Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD).
      Returns:
      the system identifier to be used in the DOCTYPE declaration in the output document.
    • getEncoding

      String getEncoding()
      Returns:
      the character encoding to be used in the output document.
    • getIndent

      boolean getIndent()
      Returns:
      true if the output document should be indented to visually indicate its structure.
    • getIndentAmount

      int getIndentAmount()
      Returns:
      the number of spaces to indent for each indentation level.
    • getMediaType

      String getMediaType()
      Returns:
      the mediatype the media-type or MIME type associated with the output document.
    • getOmitXMLDeclaration

      boolean getOmitXMLDeclaration()
      Returns:
      true if the XML declaration is to be omitted from the output document.
    • getStandalone

      String getStandalone()
      Returns:
      a value of "yes" if the standalone delaration is to be included in the output document.
    • getVersion

      String getVersion()
      Returns:
      the version of the output format.
    • setCdataSectionElements

      void setCdataSectionElements(Vector URI_and_localNames)
      Sets the value coming from the xsl:output cdata-section-elements stylesheet property. This sets the elements whose text elements are to be output as CDATA sections.
      Parameters:
      URI_and_localNames - pairs of namespace URI and local names that identify elements whose text elements are to be output as CDATA sections. The namespace of the local element must be the given URI to match. The qName is not given because the prefix does not matter, only the namespace URI to which that prefix would map matters, so the prefix itself is not relevant in specifying which elements have their text to be output as CDATA sections.
    • setDoctype

      void setDoctype(String system, String pub)
      Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
      Parameters:
      system - the system identifier to be used in the DOCTYPE declaration in the output document.
      pub - the public identifier to be used in the DOCTYPE declaration in the output document.
    • setDoctypePublic

      void setDoctypePublic(String doctype)
      Set the value coming from the xsl:output doctype-public stylesheet attribute.
      Parameters:
      doctype - the public identifier to be used in the DOCTYPE declaration in the output document.
    • setDoctypeSystem

      void setDoctypeSystem(String doctype)
      Set the value coming from the xsl:output doctype-system stylesheet attribute.
      Parameters:
      doctype - the system identifier to be used in the DOCTYPE declaration in the output document.
    • setEncoding

      void setEncoding(String encoding)
      Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
      Parameters:
      encoding - the character encoding
    • setIndent

      void setIndent(boolean indent)
      Sets the value coming from the xsl:output indent stylesheet attribute.
      Parameters:
      indent - true if the output document should be indented to visually indicate its structure.
    • setMediaType

      void setMediaType(String mediatype)
      Sets the value coming from the xsl:output media-type stylesheet attribute.
      Parameters:
      mediatype - the media-type or MIME type associated with the output document.
    • setOmitXMLDeclaration

      void setOmitXMLDeclaration(boolean b)
      Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
      Parameters:
      b - true if the XML declaration is to be omitted from the output document.
    • setStandalone

      void setStandalone(String standalone)
      Sets the value coming from the xsl:output standalone stylesheet attribute.
      Parameters:
      standalone - a value of "yes" indicates that the standalone delaration is to be included in the output document.
    • setVersion

      void setVersion(String version)
      Sets the value coming from the xsl:output version attribute.
      Parameters:
      version - the version of the output format.
    • getOutputProperty

      String getOutputProperty(String name)
      Get the value for a property that affects seraialization, if a property was set return that value, otherwise return the default value, otherwise return null.
      Parameters:
      name - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
      • "encoding"
      • "method"
      • "{http://xml.apache.org/xalan}indent-amount"
      • "{http://xml.apache.org/xalan}line-separator"
      Returns:
      The value of the parameter
    • getOutputPropertyDefault

      String getOutputPropertyDefault(String name)
      Get the default value for a property that affects seraialization, or null if there is none. It is possible that a non-default value was set for the property, however the value returned by this method is unaffected by any non-default settings.
      Parameters:
      name - The name of the property.
      Returns:
      The default value of the parameter, or null if there is no default value.
    • setOutputProperty

      void setOutputProperty(String name, String val)
      Set the non-default value for a property that affects seraialization.
      Parameters:
      name - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
      • "encoding"
      • "method"
      • "{http://xml.apache.org/xalan}indent-amount"
      • "{http://xml.apache.org/xalan}line-separator"
    • setOutputPropertyDefault

      void setOutputPropertyDefault(String name, String val)
      Set the default value for a property that affects seraialization.
      Parameters:
      name - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
      • "encoding"
      • "method"
      • "{http://xml.apache.org/xalan}indent-amount"
      • "{http://xml.apache.org/xalan}line-separator"