Class XmlWriter

java.lang.Object
com.ctc.wstx.sw.XmlWriter
Direct Known Subclasses:
BufferingXmlWriter, EncodingXmlWriter

public abstract class XmlWriter extends Object
This is the base class for actual physical xml outputters. These instances will only handle actual writing (possibly including encoding) of the serialized textual xml, and will in general not verify content being output. The exception are the character-by-character checks that are most efficiently done at encoding level (such as character escaping, and checks for illegal character combinations), which are handled at this level.

Note that implementations can have different operating modes: specifically, when dealing with illegal content (such as "--" in a comment, "?>" in processing instruction, or "]]>" within CDATA section), implementations can do one of 3 things:

  • Fix the problem, by splitting the section (which can be done for CDATA sections, and to some degree, comments)
  • Stop outputting, and return an index to the illegal piece of data (if there is no easy way to fix the problem: for example, for processing instruction)
  • Just output content even though it will not result in well-formed output. This should only be done if the calling application has specifically requested verifications to be disabled.
  • Field Details

    • SURR1_FIRST

      protected static final int SURR1_FIRST
      See Also:
    • SURR1_LAST

      protected static final int SURR1_LAST
      See Also:
    • SURR2_FIRST

      protected static final int SURR2_FIRST
      See Also:
    • SURR2_LAST

      protected static final int SURR2_LAST
      See Also:
    • DEFAULT_QUOTE_CHAR

      protected static final char DEFAULT_QUOTE_CHAR
      See Also:
    • mConfig

      protected final WriterConfig mConfig
    • mEncoding

      protected final String mEncoding
    • mNsAware

      protected final boolean mNsAware
    • mCheckStructure

      protected final boolean mCheckStructure
    • mCheckContent

      protected final boolean mCheckContent
    • mCheckNames

      protected final boolean mCheckNames
    • mFixContent

      protected final boolean mFixContent
    • mEscapeCR

      final boolean mEscapeCR
      Whether to escape CR (\r) character.
    • mAddSpaceAfterEmptyElem

      final boolean mAddSpaceAfterEmptyElem
      Whether to add a space after empty element (before closing "/>") or not.
    • mUseDoubleQuotesInXmlDecl

      final boolean mUseDoubleQuotesInXmlDecl
      Whether to use double quotes in XML declaration or not.
    • mAutoCloseOutput

      protected final boolean mAutoCloseOutput
      Flag that defines whether close() on this writer should call close on the underlying output object (stream, writer)
    • mTextWriter

      protected Writer mTextWriter
      Optional escaping writer used for escaping characters like '<' '&' and '>' in textual content. Constructed if calling code has installed a special escaping writer factory for text content. Null if the default escaper is to be used.
    • mAttrValueWriter

      protected Writer mAttrValueWriter
      Optional escaping writer used for escaping characters like '"' '&' and '<' in attribute values. Constructed if calling code has installed a special escaping writer factory for text content. Null if the default escaper is to be used.
    • mXml11

      protected boolean mXml11
      Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.
    • mRawWrapper

      protected XmlWriterWrapper mRawWrapper
      Lazy-constructed wrapper object, which will route all calls to Writer API, to matching writeRaw methods of this XmlWriter instance.
    • mTextWrapper

      protected XmlWriterWrapper mTextWrapper
      Lazy-constructed wrapper object, which will route all calls to Writer API, to matching writeCharacters methods of this XmlWriter instance.
    • mLocPastChars

      protected int mLocPastChars
      Number of characters output prior to currently buffered output
    • mLocRowNr

      protected int mLocRowNr
    • mLocRowStartOffset

      protected int mLocRowStartOffset
      Offset of the first character on this line. May be negative, if the offset was in a buffer that has been flushed out.
  • Constructor Details

  • Method Details