Class SerializerBase

java.lang.Object
org.apache.xml.serializer.SerializerBase
All Implemented Interfaces:
DOMSerializer, ExtendedContentHandler, ExtendedLexicalHandler, SerializationHandler, Serializer, ContentHandler, DTDHandler, ErrorHandler, DeclHandler, LexicalHandler
Direct Known Subclasses:
ToSAXHandler, ToStream, ToUnknownStream

public abstract class SerializerBase
extends Object
implements SerializationHandler
This class acts as a base class for the XML "serializers" and the stream serializers. It contains a number of common fields and methods.
  • Field Details

    • PKG_NAME

      public static final String PKG_NAME
      The name of the package that this class is in.

      Not a public API.

    • PKG_PATH

      public static final String PKG_PATH
      The same as the name of the package that this class is in except that '.' are replaced with '/'.

      Not a public API.

    • m_needToCallStartDocument

      protected boolean m_needToCallStartDocument
      true if we still need to call startDocumentInternal()
    • m_cdataTagOpen

      protected boolean m_cdataTagOpen
      True if a trailing "]]>" still needs to be written to be written out. Used to merge adjacent CDATA sections
    • m_attributes

      protected AttributesImplSerializer m_attributes
      All the attributes of the current element, collected from startPrefixMapping() calls, or addAddtribute() calls, or from the SAX attributes in a startElement() call.
    • m_inEntityRef

      protected boolean m_inEntityRef
      Tells if we're in an EntityRef event.
    • m_inExternalDTD

      protected boolean m_inExternalDTD
      This flag is set while receiving events from the external DTD
    • m_doctypeSystem

      protected String m_doctypeSystem
      The System ID for the doc type.
    • m_doctypePublic

      protected String m_doctypePublic
      The public ID for the doc type.
    • m_shouldNotWriteXMLHeader

      protected boolean m_shouldNotWriteXMLHeader
      Tells if we should write the XML declaration.
    • m_standaloneWasSpecified

      protected boolean m_standaloneWasSpecified
      True if standalone was specified.
    • m_doIndent

      protected boolean m_doIndent
      Flag to tell if indenting (pretty-printing) is on.
    • m_indentAmount

      protected int m_indentAmount
      Amount to indent.
    • m_version

      protected String m_version
      Tells the XML version, for writing out to the XML decl.
    • m_mediatype

      protected String m_mediatype
      The mediatype. Not used right now.
    • m_prefixMap

      protected NamespaceMappings m_prefixMap
      Namespace support, that keeps track of currently defined prefix/uri mappings. As processed elements come and go, so do the associated mappings for that element.
    • m_tracer

      protected SerializerTrace m_tracer
      Handle for firing generate events. This interface may be implemented by the referenced transformer object.
    • m_sourceLocator

      protected SourceLocator m_sourceLocator
    • m_writer

      protected Writer m_writer
      The writer to send output to. This field is only used in the ToStream serializers, but exists here just so that the fireStartDoc() and other fire... methods can flush this writer when tracing.
    • m_elemContext

      protected org.apache.xml.serializer.ElemContext m_elemContext
      A reference to "stack frame" corresponding to the current element. Such a frame is pushed at a startElement() and popped at an endElement(). This frame contains information about the element, such as its namespace URI.
    • m_charsBuff

      protected char[] m_charsBuff
      A utility buffer for converting Strings passed to character() methods to character arrays. Reusing this buffer means not creating a new character array everytime and it runs faster.
    • m_attrBuff

      protected char[] m_attrBuff
      A utility buffer for converting Strings passed to attribute methods to character arrays. Reusing this buffer means not creating a new character array everytime and it runs faster.
    • m_StringOfCDATASections

      protected String m_StringOfCDATASections
      The CDATA section names stored in a whitespace separateed list with each element being a word of the form "{uri}localName" This list comes from the cdata-section-elements attribute. This field replaces m_cdataSectionElements Vector.
    • m_CdataElems

      protected Hashtable m_CdataElems
    • CDATA_CONTINUE

      static final String CDATA_CONTINUE
      To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >
      See Also:
      Constant Field Values
    • CDATA_DELIMITER_CLOSE

      static final String CDATA_DELIMITER_CLOSE
      The constant "]]>"
      See Also:
      Constant Field Values
    • CDATA_DELIMITER_OPEN

      static final String CDATA_DELIMITER_OPEN
      See Also:
      Constant Field Values
    • EMPTYSTRING

      static final String EMPTYSTRING
      See Also:
      Constant Field Values
    • ENTITY_AMP

      static final String ENTITY_AMP
      See Also:
      Constant Field Values
    • ENTITY_CRLF

      static final String ENTITY_CRLF
      See Also:
      Constant Field Values
    • ENTITY_GT

      static final String ENTITY_GT
      See Also:
      Constant Field Values
    • ENTITY_LT

      static final String ENTITY_LT
      See Also:
      Constant Field Values
    • ENTITY_QUOT

      static final String ENTITY_QUOT
      See Also:
      Constant Field Values
    • XML_PREFIX

      static final String XML_PREFIX
      See Also:
      Constant Field Values
    • XMLNS_PREFIX

      static final String XMLNS_PREFIX
      See Also:
      Constant Field Values
    • XMLNS_URI

      static final String XMLNS_URI
      See Also:
      Constant Field Values
    • DEFAULT_SAX_SERIALIZER

      static final String DEFAULT_SAX_SERIALIZER
    • XMLVERSION11

      static final String XMLVERSION11
      Define the XML version.
      See Also:
      Constant Field Values
    • XMLVERSION10

      static final String XMLVERSION10
      See Also:
      Constant Field Values
  • Method Details

    • fireEndElem

      protected void fireEndElem​(String name) throws SAXException
      To fire off the end element trace event
      Parameters:
      name - Name of element
      Throws:
      SAXException
    • fireCharEvent

      protected void fireCharEvent​(char[] chars, int start, int length) throws SAXException
      Report the characters trace event
      Parameters:
      chars - content of characters
      start - starting index of characters to output
      length - number of characters to output
      Throws:
      SAXException
    • comment

      public void comment​(String data) throws SAXException
      Receive notification of a comment.
      Specified by:
      comment in interface ExtendedLexicalHandler
      Parameters:
      data - the comment, but unlike the SAX comment() method this method takes a String rather than a character array.
      Throws:
      SAXException
      See Also:
      ExtendedLexicalHandler.comment(String)
    • patchName

      protected String patchName​(String qname)
      If at runtime, when the qname of the attribute is known, another prefix is specified for the attribute, then we can patch or hack the name with this method. For a qname of the form "ns?:otherprefix:name", this function patches the qname by simply ignoring "otherprefix". TODO: This method is a HACK! We do not have access to the XML file, it sometimes generates a NS prefix of the form "ns?" for an attribute.
    • getLocalName

      protected static String getLocalName​(String qname)
      Returns the local name of a qualified name. If the name has no prefix, then it works as the identity (SAX2).
      Parameters:
      qname - the qualified name
      Returns:
      the name, but excluding any prefix and colon.
    • setDocumentLocator

      public void setDocumentLocator​(Locator locator)
      Receive an object for locating the origin of SAX document events.
      Specified by:
      setDocumentLocator in interface ContentHandler
      Parameters:
      locator - An object that can return the location of any SAX document event. Receive an object for locating the origin of SAX document events.

      SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

      The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

      Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

      See Also:
      Locator
    • addAttribute

      public void addAttribute​(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException
      Adds the given attribute to the set of collected attributes , but only if there is a currently open element. An element is currently open if a startElement() notification has occured but the start of the element has not yet been written to the output. In the stream case this means that we have not yet been forced to close the elements opening tag by another notification, such as a character notification.
      Specified by:
      addAttribute in interface ExtendedContentHandler
      Parameters:
      uri - the URI of the attribute
      localName - the local name of the attribute
      rawName - the qualified name of the attribute
      type - the type of the attribute (probably CDATA)
      value - the value of the attribute
      XSLAttribute - true if this attribute is coming from an xsl:attriute element
      Throws:
      SAXException
      See Also:
      ExtendedContentHandler.addAttribute(String, String, String, String, String)
    • addAttributeAlways

      public boolean addAttributeAlways​(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)
      Adds the given attribute to the set of attributes, even if there is no currently open element. This is useful if a SAX startPrefixMapping() should need to add an attribute before the element name is seen.
      Parameters:
      uri - the URI of the attribute
      localName - the local name of the attribute
      rawName - the qualified name of the attribute
      type - the type of the attribute (probably CDATA)
      value - the value of the attribute
      XSLAttribute - true if this attribute is coming from an xsl:attribute element
      Returns:
      true if the attribute was added, false if an existing value was replaced.
    • addAttribute

      public void addAttribute​(String name, String value)
      Adds the given attribute to the set of collected attributes, but only if there is a currently open element.
      Specified by:
      addAttribute in interface ExtendedContentHandler
      Parameters:
      name - the attribute's qualified name
      value - the value of the attribute
    • addXSLAttribute

      public void addXSLAttribute​(String name, String value, String uri)
      Adds the given xsl:attribute to the set of collected attributes, but only if there is a currently open element.
      Specified by:
      addXSLAttribute in interface ExtendedContentHandler
      Parameters:
      name - the attribute's qualified name (prefix:localName)
      value - the value of the attribute
      uri - the URI that the prefix of the name points to
    • addAttributes

      public void addAttributes​(Attributes atts) throws SAXException
      Add the given attributes to the currently collected ones. These attributes are always added, regardless of whether on not an element is currently open.
      Specified by:
      addAttributes in interface ExtendedContentHandler
      Parameters:
      atts - List of attributes to add to this list
      Throws:
      SAXException
    • asContentHandler

      public ContentHandler asContentHandler() throws IOException
      Return a ContentHandler interface into this serializer. If the serializer does not support the ContentHandler interface, it should return null.
      Specified by:
      asContentHandler in interface Serializer
      Returns:
      A ContentHandler interface into this serializer, or null if the serializer is not SAX 2 capable
      Throws:
      IOException - An I/O exception occured
    • endEntity

      public void endEntity​(String name) throws SAXException
      Report the end of an entity.
      Specified by:
      endEntity in interface LexicalHandler
      Parameters:
      name - The name of the entity that is ending.
      Throws:
      SAXException - The application may raise an exception.
      See Also:
      LexicalHandler.startEntity(java.lang.String)
    • close

      public void close()
      Flush and close the underlying java.io.Writer. This method applies to ToStream serializers, not ToSAXHandler serializers.
      Specified by:
      close in interface SerializationHandler
      See Also:
      ToStream
    • initCDATA

      protected void initCDATA()
      Initialize global variables
    • getEncoding

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

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

      public 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.
    • getOmitXMLDeclaration

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

      public 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.
    • setDoctypePublic

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

      public 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.
    • setDoctypeSystem

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

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

      public 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. This method remembers if the value was explicitly set using this method, verses if the value is the default value.
    • setStandaloneInternal

      protected void setStandaloneInternal​(String standalone)
      Sets the XSL standalone attribute, but does not remember if this is a default or explicite setting.
      Parameters:
      standalone - "yes" | "no"
    • getStandalone

      public String getStandalone()
      Gets the XSL standalone attribute
      Returns:
      a value of "yes" if the standalone delaration is to be included in the output document.
      See Also:
      XSLOutputAttributes.getStandalone()
    • getIndent

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

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

      public String getVersion()
      Gets the version of the output format.
      Returns:
      the version of the output format.
    • setVersion

      public void setVersion​(String version)
      Sets the value coming from the xsl:output version attribute.
      Parameters:
      version - the version of the output format.
      See Also:
      XSLOutputAttributes.setVersion(String)
    • setMediaType

      public void setMediaType​(String mediaType)
      Sets the value coming from the xsl:output media-type stylesheet attribute.
      Parameters:
      mediaType - the non-null media-type or MIME type associated with the output document.
      See Also:
      OutputKeys.MEDIA_TYPE, XSLOutputAttributes.setMediaType(String)
    • getIndentAmount

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

      public void setIndentAmount​(int m_indentAmount)
      Sets the indentation amount.
      Specified by:
      setIndentAmount in interface SerializationHandler
      Parameters:
      m_indentAmount - The m_indentAmount to set
    • setIndent

      public void setIndent​(boolean doIndent)
      Sets the value coming from the xsl:output indent stylesheet attribute.
      Parameters:
      doIndent - true if the output document should be indented to visually indicate its structure.
      See Also:
      XSLOutputAttributes.setIndent(boolean)
    • namespaceAfterStartElement

      public void namespaceAfterStartElement​(String uri, String prefix) throws SAXException
      This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.
      Specified by:
      namespaceAfterStartElement in interface ExtendedContentHandler
      Parameters:
      uri - the URI of the namespace
      prefix - the prefix associated with the given URI.
      Throws:
      SAXException
      See Also:
      ExtendedContentHandler.namespaceAfterStartElement(String, String)
    • asDOMSerializer

      public DOMSerializer asDOMSerializer() throws IOException
      Return a DOMSerializer interface into this serializer. If the serializer does not support the DOMSerializer interface, it should return null.
      Specified by:
      asDOMSerializer in interface Serializer
      Returns:
      A DOMSerializer interface into this serializer, or null if the serializer is not DOM capable
      Throws:
      IOException - An I/O exception occured
      See Also:
      Serializer.asDOMSerializer()
    • getPrefixPart

      protected static final String getPrefixPart​(String qname)
      Returns the local name of a qualified name. If the name has no prefix, then it works as the identity (SAX2).
      Parameters:
      qname - a qualified name
      Returns:
      returns the prefix of the qualified name, or null if there is no prefix.
    • getNamespaceMappings

      public NamespaceMappings getNamespaceMappings()
      Some users of the serializer may need the current namespace mappings
      Specified by:
      getNamespaceMappings in interface ExtendedContentHandler
      Returns:
      the current namespace mappings (prefix/uri)
      See Also:
      ExtendedContentHandler.getNamespaceMappings()
    • getPrefix

      public String getPrefix​(String namespaceURI)
      Returns the prefix currently pointing to the given URI (if any).
      Specified by:
      getPrefix in interface ExtendedContentHandler
      Parameters:
      namespaceURI - the uri of the namespace in question
      Returns:
      a prefix pointing to the given URI (if any).
      See Also:
      ExtendedContentHandler.getPrefix(String)
    • getNamespaceURI

      public String getNamespaceURI​(String qname, boolean isElement)
      Returns the URI of an element or attribute. Note that default namespaces do not apply directly to attributes.
      Specified by:
      getNamespaceURI in interface ExtendedContentHandler
      Parameters:
      qname - a qualified name
      isElement - true if the qualified name is the name of an element.
      Returns:
      returns the namespace URI associated with the qualified name.
    • getNamespaceURIFromPrefix

      public String getNamespaceURIFromPrefix​(String prefix)
      Returns the URI of prefix (if any)
      Specified by:
      getNamespaceURIFromPrefix in interface ExtendedContentHandler
      Parameters:
      prefix - the prefix whose URI is searched for
      Returns:
      the namespace URI currently associated with the prefix, null if the prefix is undefined.
    • entityReference

      public void entityReference​(String name) throws SAXException
      Entity reference event.
      Specified by:
      entityReference in interface ExtendedContentHandler
      Parameters:
      name - Name of entity
      Throws:
      SAXException
    • setTransformer

      public void setTransformer​(Transformer t)
      Sets the transformer associated with this serializer
      Specified by:
      setTransformer in interface SerializationHandler
      Parameters:
      t - the transformer associated with this serializer.
      See Also:
      SerializationHandler.setTransformer(Transformer)
    • getTransformer

      public Transformer getTransformer()
      Gets the transformer associated with this serializer
      Specified by:
      getTransformer in interface SerializationHandler
      Returns:
      returns the transformer associated with this serializer.
      See Also:
      SerializationHandler.getTransformer()
    • characters

      public void characters​(Node node) throws SAXException
      This method gets the nodes value as a String and uses that String as if it were an input character notification.
      Specified by:
      characters in interface ExtendedContentHandler
      Parameters:
      node - the Node to serialize
      Throws:
      SAXException
    • error

      public void error​(SAXParseException exc) throws SAXException
      Description copied from interface: ErrorHandler
      Receive notification of a recoverable error.

      This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

      The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML recommendation does not require it to do so.

      Filters may use this method to report other, non-XML errors as well.

      Specified by:
      error in interface ErrorHandler
      Parameters:
      exc - The error information encapsulated in a SAX parse exception.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      See Also:
      ErrorHandler.error(SAXParseException)
    • fatalError

      public void fatalError​(SAXParseException exc) throws SAXException
      Description copied from interface: ErrorHandler
      Receive notification of a non-recoverable error.

      There is an apparent contradiction between the documentation for this method and the documentation for ContentHandler.endDocument(). Until this ambiguity is resolved in a future major release, clients should make no assumptions about whether endDocument() will or will not be invoked when the parser has reported a fatalError() or thrown an exception.

      This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.

      The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting additional error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.

      Specified by:
      fatalError in interface ErrorHandler
      Parameters:
      exc - The error information encapsulated in a SAX parse exception.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      See Also:
      ErrorHandler.fatalError(SAXParseException)
    • warning

      public void warning​(SAXParseException exc) throws SAXException
      Description copied from interface: ErrorHandler
      Receive notification of a warning.

      SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML recommendation. The default behaviour is to take no action.

      The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

      Filters may use this method to report other, non-XML warnings as well.

      Specified by:
      warning in interface ErrorHandler
      Parameters:
      exc - The warning information encapsulated in a SAX parse exception.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      See Also:
      ErrorHandler.warning(SAXParseException)
    • fireStartEntity

      protected void fireStartEntity​(String name) throws SAXException
      To fire off start entity trace event
      Parameters:
      name - Name of entity
      Throws:
      SAXException
    • fireCDATAEvent

      protected void fireCDATAEvent​(char[] chars, int start, int length) throws SAXException
      Report the CDATA trace event
      Parameters:
      chars - content of CDATA
      start - starting index of characters to output
      length - number of characters to output
      Throws:
      SAXException
    • fireCommentEvent

      protected void fireCommentEvent​(char[] chars, int start, int length) throws SAXException
      Report the comment trace event
      Parameters:
      chars - content of comment
      start - starting index of comment to output
      length - number of characters to output
      Throws:
      SAXException
    • fireEndEntity

      public void fireEndEntity​(String name) throws SAXException
      To fire off end entity trace event
      Parameters:
      name - Name of entity
      Throws:
      SAXException
    • fireStartDoc

      protected void fireStartDoc() throws SAXException
      To fire off start document trace event
      Throws:
      SAXException
    • fireEndDoc

      protected void fireEndDoc() throws SAXException
      To fire off end document trace event
      Throws:
      SAXException
    • fireStartElem

      protected void fireStartElem​(String elemName) throws SAXException
      Report the start element trace event. This trace method needs to be called just before the attributes are cleared.
      Parameters:
      elemName - the qualified name of the element
      Throws:
      SAXException
    • fireEscapingEvent

      protected void fireEscapingEvent​(String name, String data) throws SAXException
      To fire off the PI trace event
      Parameters:
      name - Name of PI
      Throws:
      SAXException
    • fireEntityReference

      protected void fireEntityReference​(String name) throws SAXException
      To fire off the entity reference trace event
      Parameters:
      name - Name of entity reference
      Throws:
      SAXException
    • startDocument

      public void startDocument() throws SAXException
      Receive notification of the beginning of a document. This method is never a self generated call, but only called externally.

      The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).

      Specified by:
      startDocument in interface ContentHandler
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      SAXException
      See Also:
      ContentHandler.endDocument()
    • startDocumentInternal

      protected void startDocumentInternal() throws SAXException
      This method handles what needs to be done at a startDocument() call, whether from an external caller, or internally called in the serializer. For historical reasons the serializer is flexible to startDocument() not always being called. Even if no external call is made into startDocument() this method will always be called as a self generated internal startDocument, it handles what needs to be done at a startDocument() call. This method exists just to make sure that startDocument() is only ever called from an external caller, which in principle is just a matter of style.
      Throws:
      SAXException
    • setSourceLocator

      public void setSourceLocator​(SourceLocator locator)
      This method is used to set the source locator, which might be used to generated an error message.
      Specified by:
      setSourceLocator in interface ExtendedContentHandler
      Parameters:
      locator - the source locator
      See Also:
      ExtendedContentHandler.setSourceLocator(javax.xml.transform.SourceLocator)
    • setNamespaceMappings

      public void setNamespaceMappings​(NamespaceMappings mappings)
      Used only by TransformerSnapshotImpl to restore the serialization to a previous state.
      Specified by:
      setNamespaceMappings in interface SerializationHandler
      Parameters:
      mappings - NamespaceMappings
    • reset

      public boolean reset()
      Description copied from interface: Serializer
      This method resets the serializer. If this method returns true, the serializer may be used for subsequent serialization of new documents. It is possible to change the output format and output stream prior to serializing, or to reuse the existing output format and output stream or writer.
      Specified by:
      reset in interface Serializer
      Returns:
      True if serializer has been reset and can be reused
    • addAttribute

      public void addAttribute​(String uri, String localName, String rawName, String type, String value) throws SAXException
      This method adds an attribute the the current element, but should not be used for an xsl:attribute child.
      Specified by:
      addAttribute in interface ExtendedContentHandler
      Parameters:
      uri - the namespace URI of the attribute name
      localName - the local name of the attribute (without prefix)
      rawName - the qualified name of the attribute
      type - the attribute type typically character data (CDATA)
      value - the value of the attribute
      Throws:
      SAXException
      See Also:
      ExtendedContentHandler.addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    • notationDecl

      public void notationDecl​(String arg0, String arg1, String arg2) throws SAXException
      Description copied from interface: DTDHandler
      Receive notification of a notation declaration event.

      It is up to the application to record the notation for later reference, if necessary; notations may appear as attribute values and in unparsed entity declarations, and are sometime used with processing instruction target names.

      At least one of publicId and systemId must be non-null. If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application through this event.

      There is no guarantee that the notation declaration will be reported before any unparsed entities that use it.

      Specified by:
      notationDecl in interface DTDHandler
      Parameters:
      arg0 - The notation name.
      arg1 - The notation's public identifier, or null if none was given.
      arg2 - The notation's system identifier, or null if none was given.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      See Also:
      DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
    • unparsedEntityDecl

      public void unparsedEntityDecl​(String arg0, String arg1, String arg2, String arg3) throws SAXException
      Description copied from interface: DTDHandler
      Receive notification of an unparsed entity declaration event.

      Note that the notation name corresponds to a notation reported by the notationDecl event. It is up to the application to record the entity for later reference, if necessary; unparsed entities may appear as attribute values.

      If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

      Specified by:
      unparsedEntityDecl in interface DTDHandler
      Parameters:
      arg0 - The unparsed entity's name.
      arg1 - The entity's public identifier, or null if none was given.
      arg2 - The entity's system identifier.
      arg3 - The name of the associated notation.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
      See Also:
      DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    • setDTDEntityExpansion

      public void setDTDEntityExpansion​(boolean expand)
      If set to false the serializer does not expand DTD entities, but leaves them as is, the default value is true.
      Specified by:
      setDTDEntityExpansion in interface SerializationHandler
      Parameters:
      expand - true if DTD entities are to be expanded, false if they are to be left as DTD entity references.
    • documentIsEmpty

      public boolean documentIsEmpty()
      Return true if nothing has been sent to this result tree yet.

      This is not a public API.

    • isCdataSection

      protected boolean isCdataSection()
      Return true if the current element in m_elemContext is a CDATA section. CDATA sections are specified in the attribute cdata-section-names or in the JAXP equivalent property. In any case the format of the value of such a property is:
       "{uri1}localName1 {uri2}localName2 . . . "
       

      This method is not a public API, but is only used internally by the serializer.

    • getOutputProperty

      public String getOutputProperty​(String name)
      Get the value of an output property, the explicit value, if any, otherwise the default value, if any, otherwise null.
    • getOutputPropertyNonDefault

      public String getOutputPropertyNonDefault​(String name)
      Get the value of an output property, not the default value. If there is a default value, but no non-default value this method will return null.

    • asDOM3Serializer

      public Object asDOM3Serializer() throws IOException
      Return a DOM3Serializer interface into this serializer. If the serializer does not support the DOM3Serializer interface, it should return null.
      Specified by:
      asDOM3Serializer in interface Serializer
      Returns:
      A DOM3Serializer interface into this serializer, or null if the serializer is not DOM capable
      Throws:
      IOException - An I/O exception occured
      See Also:
      Serializer.asDOM3Serializer()
    • getOutputPropertyDefault

      public String getOutputPropertyDefault​(String name)
      Get the default value of an xsl:output property, which would be null only if no default value exists for the property.
    • setOutputProperty

      public void setOutputProperty​(String name, String val)
      Set the value for the output property, typically from an xsl:output element, but this does not change what the default value is.
    • setOutputPropertyDefault

      public void setOutputPropertyDefault​(String name, String val)
      Set the default value for an output property, but this does not impact any explicitly set value.
    • 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.