BEA Systems, Inc.


weblogic.apache.xalan.serialize
Class SerializerToXML

java.lang.Object
  |
  +--weblogic.apache.xalan.serialize.SerializerToXML
Direct Known Subclasses:
SerializerToHTML, SerializerToText

public class SerializerToXML
extends java.lang.Object
implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.ext.DeclHandler, Serializer, DOMSerializer

SerializerToXML formats SAX-style events into XML.

This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.


Field Summary
protected  int level
          Current level of indent.
protected  java.util.Vector m_cdataSectionNames
          List of QNames obtained from the xsl:output properties.
protected  BoolStack m_cdataSectionStates
          True will be pushed, if characters should be in CDATA section blocks.
protected  CharInfo m_charInfo
          Map that tells which characters should have special treatment, and it provides character to entity name lookup.
protected  int m_currentIndent
          Flag to keep track of the indent amount.
protected  BoolStack m_disableOutputEscapingStates
          Stack to keep track of disabling output escaping.
protected  boolean m_doIndent
          Flag to tell if indenting (pretty-printing) is on.
protected  BoolStack m_elemStack
          A stack of Boolean objects that tell if the given element has children.
protected  java.lang.String m_encoding
          The character encoding.
protected  java.util.Properties m_format
          The xsl:output properties.
protected  boolean m_inCData
          True if the current characters should be in CDATA blocks.
 int m_indentAmount
          Amount to indent.
protected  boolean m_inEntityRef
          Tells if we're in an EntityRef event.
protected  boolean m_ispreserve
          State flag to tell if preservation of whitespace is important.
protected  boolean m_isprevtext
          State flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace.
protected  char[] m_lineSep
          Use the system line seperator to write line breaks.
protected  int m_lineSepLen
          The length of the line seperator, since the write is done one character at a time.
protected  int m_maxCharacter
          The maximum character size before we have to resort to escaping.
protected  int m_pos
          The current position in the m_charBuf or m_byteBuf.
protected  BoolStack m_preserves
          Stack to keep track of whether or not we need to preserve whitespace.
 boolean m_shouldNotWriteXMLHeader
          Tells if we should write the XML declaration.
 boolean m_spaceBeforeClose
          Add space before '/>' for XHTML.
 java.lang.String m_version
          Tells the XML version, for writing out to the XML decl.
protected  java.io.Writer m_writer
          The writer where the XML will be written.
protected static CharInfo m_xmlcharInfo
          Map that tells which XML characters should have special treatment, and it provides character to entity name lookup.
 
Constructor Summary
SerializerToXML()
          Default constructor.
 
Method Summary
protected  void accum(char b)
          Append a character to the buffer.
protected  void accum(char[] chars, int start, int length)
          Append a character to the buffer.
protected  void accum(java.lang.String s)
          Append a character to the buffer.
protected  int accumDefaultEntity(char ch, int i, char[] chars, int len, boolean escLF)
          Handle one of the default entities, return false if it is not a default entity.
protected  int accumDefaultEscape(char ch, int i, char[] chars, int len, boolean escLF)
          Escape and m_writer.write a character.
 org.xml.sax.ContentHandler asContentHandler()
          Return a ContentHandler interface into this serializer.
 DOMSerializer asDOMSerializer()
          Return a DOMSerializer interface into this serializer.
 void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
          Report an attribute type declaration.
 boolean canConvert(char ch)
          Tell if this character can be written without escaping.
 void cdata(char[] ch, int start, int length)
          Receive notification of cdata.
 void characters(char[] chars, int start, int length)
          Receive notification of character data.
 void charactersRaw(char[] ch, int start, int length)
          If available, when the disable-output-escaping attribute is used, output raw text without escaping.
protected  boolean childNodesWereAdded()
          Tell if child nodes have been added to the current element.
 void comment(char[] ch, int start, int length)
          Report an XML comment anywhere in the document.
 void CopyFrom(SerializerToXML xmlListener)
          Copy properties from another SerializerToXML.
 void elementDecl(java.lang.String name, java.lang.String model)
          Report an element type declaration.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Receive notification of the end of a document.
 void endDTD()
          Report the end of DTD declarations.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name)
          Receive notification of the end of an element.
 void endEntity(java.lang.String name)
          Report the end of an entity.
 void endNonEscaping()
          Ends an un-escaping section.
 void endPrefixMapping(java.lang.String prefix)
          End the scope of a prefix-URI Namespace mapping.
 void endPreserving()
          Ends a whitespace preserving section.
 void entityReference(java.lang.String name)
          Receive notivication of a entityReference.
 void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report a parsed external entity declaration.
 void flushWriter()
          Flush the formatter's result stream.
 java.util.Properties getOutputFormat()
          Returns the output format for this serializer.
 java.io.OutputStream getOutputStream()
          Get the output stream where the events will be serialized to.
 java.io.Writer getWriter()
          Get the character stream where the events will be serialized to.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
 void indent(int n)
          Prints a newline character and n spaces.
 void init(java.io.OutputStream output, java.util.Properties format)
          Initialize the serializer with the specified output stream and output format.
 void init(java.io.Writer writer, java.util.Properties format)
          Initialize the serializer with the specified writer and output format.
 void internalEntityDecl(java.lang.String name, java.lang.String value)
          Report an internal entity declaration.
protected  boolean isCDataSection()
          Tell if the characters in the current state should be put in cdata section blocks.
protected  boolean isEscapingDisabled()
          Tell if the character escaping should be disabled for the current state.
protected  void openElementForChildren()
          Flag the current element as not yet having any children.
protected  void outputLineSep()
          Output a system-dependent line break.
 void printSpace(int n)
          Prints n spaces.
protected  void processAttribute(java.lang.String name, java.lang.String value)
          Process an attribute.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
protected  void pushState(java.lang.String namespaceURI, java.lang.String localName, java.util.Vector qnames, BoolStack state)
          Push a boolean state based on if the name of the element is found in the list of qnames.
 boolean reset()
          Resets the serializer.
 void serialize(org.w3c.dom.Node node)
          Serializes the DOM node.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Receive an object for locating the origin of SAX document events.
 void setOutputFormat(java.util.Properties format)
          Specifies an output format for this serializer.
 void setOutputStream(java.io.OutputStream output)
          Specifies an output stream to which the document should be serialized.
 void setWriter(java.io.Writer writer)
          Specifies a writer to which the document should be serialized.
protected  boolean shouldIndent()
          Tell if, based on space preservation constraints and the doIndent property, if an indent should occur.
 void skippedEntity(java.lang.String name)
          Receive notification of a skipped entity.
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Receive notification of the beginning of a document.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report the start of DTD declarations, if any.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element.
 void startEntity(java.lang.String name)
          Report the beginning of an entity.
 void startNonEscaping()
          Starts an un-escaping section.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Begin the scope of a prefix-URI Namespace mapping.
 void startPreserving()
          Starts a whitespace preserving section.
protected static boolean subPartMatch(java.lang.String p, java.lang.String t)
          Tell if two strings are equal, without worry if the first string is null.
 void writeAttrString(java.lang.String string, java.lang.String encoding)
          Returns the specified string after substituting specials, and UTF-16 surrogates for chracter references &#xnn.
protected  void writeParentTagEnd()
          Check to see if a parent's ">" has been written, and, if it has not, write it.
protected  int writeUTF16Surrogate(char c, char[] ch, int i, int end)
          Once a surrogate has been detected, write the pair as a single character reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_writer

protected java.io.Writer m_writer
The writer where the XML will be written.

m_encoding

protected java.lang.String m_encoding
The character encoding. Must match the encoding used for the printWriter.

m_shouldNotWriteXMLHeader

public boolean m_shouldNotWriteXMLHeader
Tells if we should write the XML declaration.

m_version

public java.lang.String m_version
Tells the XML version, for writing out to the XML decl.

m_elemStack

protected BoolStack m_elemStack
A stack of Boolean objects that tell if the given element has children.

m_disableOutputEscapingStates

protected BoolStack m_disableOutputEscapingStates
Stack to keep track of disabling output escaping.

m_cdataSectionStates

protected BoolStack m_cdataSectionStates
True will be pushed, if characters should be in CDATA section blocks.

m_cdataSectionNames

protected java.util.Vector m_cdataSectionNames
List of QNames obtained from the xsl:output properties.

m_inCData

protected boolean m_inCData
True if the current characters should be in CDATA blocks.

m_lineSep

protected final char[] m_lineSep
Use the system line seperator to write line breaks.

m_lineSepLen

protected final int m_lineSepLen
The length of the line seperator, since the write is done one character at a time.

m_ispreserve

protected boolean m_ispreserve
State flag to tell if preservation of whitespace is important.

m_preserves

protected BoolStack m_preserves
Stack to keep track of whether or not we need to preserve whitespace.

m_isprevtext

protected boolean m_isprevtext
State flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace.

m_doIndent

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

m_currentIndent

protected int m_currentIndent
Flag to keep track of the indent amount.

m_indentAmount

public int m_indentAmount
Amount to indent.

level

protected int level
Current level of indent.

m_inEntityRef

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

m_xmlcharInfo

protected static CharInfo m_xmlcharInfo
Map that tells which XML characters should have special treatment, and it provides character to entity name lookup.

m_charInfo

protected CharInfo m_charInfo
Map that tells which characters should have special treatment, and it provides character to entity name lookup.

m_maxCharacter

protected int m_maxCharacter
The maximum character size before we have to resort to escaping.

m_spaceBeforeClose

public boolean m_spaceBeforeClose
Add space before '/>' for XHTML.

m_format

protected java.util.Properties m_format
The xsl:output properties.

m_pos

protected int m_pos
The current position in the m_charBuf or m_byteBuf.
Constructor Detail

SerializerToXML

public SerializerToXML()
Default constructor.
Method Detail

isEscapingDisabled

protected boolean isEscapingDisabled()
Tell if the character escaping should be disabled for the current state.

Returns:
true if the character escaping should be disabled.

isCDataSection

protected boolean isCDataSection()
Tell if the characters in the current state should be put in cdata section blocks.

Returns:
true if the characters in the current state should be put in cdata section blocks.

outputLineSep

protected final void outputLineSep()
                            throws org.xml.sax.SAXException
Output a system-dependent line break.

Throws:
org.xml.sax.SAXException -  

CopyFrom

public void CopyFrom(SerializerToXML xmlListener)
Copy properties from another SerializerToXML.

Parameters:
xmlListener - non-null reference to a SerializerToXML object.

init

public void init(java.io.Writer writer,
                 java.util.Properties format)
Initialize the serializer with the specified writer and output format. Must be called before calling any of the serialize methods.

Parameters:
writer - The writer to use
format - The output format

init

public void init(java.io.OutputStream output,
                 java.util.Properties format)
          throws java.io.UnsupportedEncodingException
Initialize the serializer with the specified output stream and output format. Must be called before calling any of the serialize methods.

Parameters:
output - The output stream to use
format - The output format
Throws:
java.io.UnsupportedEncodingException - The encoding specified in the output format is not supported

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Receive an object for locating the origin of SAX document events.
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

Parameters:
locator - An object that can return the location of any SAX document event.
See Also:
Locator

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification of the beginning of a document.
Specified by:
startDocument in interface org.xml.sax.ContentHandler

Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Receive notification of the end of a document.
Specified by:
endDocument in interface org.xml.sax.ContentHandler

Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Report the start of DTD declarations, if any. Any declarations are assumed to be in the internal subset unless otherwise indicated.
Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler

Parameters:
name - The document type name.
publicId - The declared public identifier for the external DTD subset, or null if none was declared.
systemId - The declared system identifier for the external DTD subset, or null if none was declared.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endDTD(), startEntity(java.lang.String)

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Report the end of DTD declarations.
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Begin the scope of a prefix-URI Namespace mapping.
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler

Parameters:
prefix - The Namespace prefix being declared.
uri - The Namespace URI the prefix is mapped to.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
End the scope of a prefix-URI Namespace mapping.
Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler

Parameters:
prefix - The prefix that was being mapping.
Throws:
org.xml.sax.SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

subPartMatch

protected static final boolean subPartMatch(java.lang.String p,
                                            java.lang.String t)
Tell if two strings are equal, without worry if the first string is null.

Parameters:
p - String reference, which may be null.
t - String reference, which may be null.
Returns:
true if strings are equal.

pushState

protected void pushState(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.util.Vector qnames,
                         BoolStack state)
Push a boolean state based on if the name of the element is found in the list of qnames. A state is always pushed, one way or the other.

Parameters:
namespaceURI - Should be a non-null reference to the namespace URL of the element that owns the state, or empty string.
localName - Should be a non-null reference to the local name of the element that owns the state.
qnames - Vector of qualified names of elements, or null.
state - The stack where the state should be pushed.

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element.
Specified by:
startElement in interface org.xml.sax.ContentHandler

Parameters:
namespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
name - The element type name.
atts - The attributes attached to the element, if any.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes), ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String), AttributeList

writeParentTagEnd

protected void writeParentTagEnd()
                          throws org.xml.sax.SAXException
Check to see if a parent's ">" has been written, and, if it has not, write it.

Throws:
org.xml.sax.SAXException -  

openElementForChildren

protected void openElementForChildren()
Flag the current element as not yet having any children.


childNodesWereAdded

protected boolean childNodesWereAdded()
Tell if child nodes have been added to the current element. Must be called in balance with openElementForChildren().

Returns:
true if child nodes were added.

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
Receive notification of the end of an element.
Specified by:
endElement in interface org.xml.sax.ContentHandler

Parameters:
namespaceURI - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
name - The element type name
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  

processAttribute

protected void processAttribute(java.lang.String name,
                                java.lang.String value)
                         throws org.xml.sax.SAXException
Process an attribute.

Parameters:
name - The name of the attribute.
value - The value of the attribute.
Throws:
org.xml.sax.SAXException -  

startNonEscaping

public void startNonEscaping()
                      throws org.xml.sax.SAXException
Starts an un-escaping section. All characters printed within an un-escaping section are printed as is, without escaping special characters into entity references. Only XML and HTML serializers need to support this method.

The contents of the un-escaping section will be delivered through the regular characters event.

Throws:
org.xml.sax.SAXException -  

endNonEscaping

public void endNonEscaping()
                    throws org.xml.sax.SAXException
Ends an un-escaping section.

Throws:
org.xml.sax.SAXException -  
See Also:
startNonEscaping()

startPreserving

public void startPreserving()
                     throws org.xml.sax.SAXException
Starts a whitespace preserving section. All characters printed within a preserving section are printed without indentation and without consolidating multiple spaces. This is equivalent to the xml:space="preserve" attribute. Only XML and HTML serializers need to support this method.

The contents of the whitespace preserving section will be delivered through the regular characters event.

Throws:
org.xml.sax.SAXException -  

endPreserving

public void endPreserving()
                   throws org.xml.sax.SAXException
Ends a whitespace preserving section.

Throws:
org.xml.sax.SAXException -  
See Also:
startPreserving()

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Receive notification of a processing instruction.
Specified by:
processingInstruction in interface org.xml.sax.ContentHandler

Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none was supplied.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Report an XML comment anywhere in the document. This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).
Specified by:
comment in interface org.xml.sax.ext.LexicalHandler

Parameters:
ch - An array holding the characters in the comment.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Report the start of a CDATA section.
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endCDATA()

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Report the end of a CDATA section.
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler

Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startCDATA()

cdata

public void cdata(char[] ch,
                  int start,
                  int length)
           throws org.xml.sax.SAXException
Receive notification of cdata.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  
See Also:
ignorableWhitespace(char[], int, int), Locator

accum

protected final void accum(char b)
                    throws org.xml.sax.SAXException
Append a character to the buffer.

Parameters:
b - byte to be written to result stream.
Throws:
org.xml.sax.SAXException -  

accum

protected final void accum(char[] chars,
                           int start,
                           int length)
                    throws org.xml.sax.SAXException
Append a character to the buffer.

Parameters:
chars - non-null reference to character array.
start - Start of characters to be written.
length - Number of characters to be written.
Throws:
org.xml.sax.SAXException -  

accum

protected final void accum(java.lang.String s)
                    throws org.xml.sax.SAXException
Append a character to the buffer.

Parameters:
s - non-null reference to string to be written to the character buffer.
Throws:
org.xml.sax.SAXException -  

flushWriter

public final void flushWriter()
                       throws org.xml.sax.SAXException
Flush the formatter's result stream.

Throws:
org.xml.sax.SAXException -  

characters

public void characters(char[] chars,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).

Specified by:
characters in interface org.xml.sax.ContentHandler

Parameters:
chars - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  
See Also:
ignorableWhitespace(char[], int, int), Locator

charactersRaw

public void charactersRaw(char[] ch,
                          int start,
                          int length)
                   throws org.xml.sax.SAXException
If available, when the disable-output-escaping attribute is used, output raw text without escaping.

Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException -  

writeUTF16Surrogate

protected int writeUTF16Surrogate(char c,
                                  char[] ch,
                                  int i,
                                  int end)
                           throws java.io.IOException,
                                  org.xml.sax.SAXException
Once a surrogate has been detected, write the pair as a single character reference.

Parameters:
c - the first part of the surrogate.
ch - Character array.
i - position Where the surrogate was detected.
end - The end index of the significant characters.
Returns:
i+1.
Throws:
java.io.IOException -  
org.xml.sax.SAXException - if invalid UTF-16 surrogate detected.

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content. Not sure how to get this invoked quite yet.
Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler

Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
org.xml.sax.SAXException -  
See Also:
characters(char[], int, int)

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Receive notification of a skipped entity.
Specified by:
skippedEntity in interface org.xml.sax.ContentHandler

Parameters:
name - The name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]".
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.skippedEntity(java.lang.String)

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Report the beginning of an entity. The start and end of the document entity are not reported. The start and end of the external DTD subset are reported using the pseudo-name "[dtd]". All other events must be properly nested within start/end entity events.
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
endEntity(java.lang.String), DeclHandler.internalEntityDecl(java.lang.String, java.lang.String), DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
Report the end of an entity.
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler

Parameters:
name - The name of the entity that is ending.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
startEntity(java.lang.String)

entityReference

public void entityReference(java.lang.String name)
                     throws org.xml.sax.SAXException
Receive notivication of a entityReference.

Parameters:
name - The name of the entity.
Throws:
org.xml.sax.SAXException -  

elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String model)
                 throws org.xml.sax.SAXException
Report an element type declaration.

The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all whitespace is removed,and will include the enclosing parentheses.

Specified by:
elementDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The element type name.
model - The content model as a normalized string.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

attributeDecl

public void attributeDecl(java.lang.String eName,
                          java.lang.String aName,
                          java.lang.String type,
                          java.lang.String valueDefault,
                          java.lang.String value)
                   throws org.xml.sax.SAXException
Report an attribute type declaration.

Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.

Specified by:
attributeDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
eName - The name of the associated element.
aName - The name of the attribute.
type - A string representing the attribute type.
valueDefault - A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
value - A string representing the attribute's default value, or null if there is none.
Throws:
org.xml.sax.SAXException - The application may raise an exception.

internalEntityDecl

public void internalEntityDecl(java.lang.String name,
                               java.lang.String value)
                        throws org.xml.sax.SAXException
Report an internal entity declaration.

Only the effective (first) declaration for each entity will be reported.

Specified by:
internalEntityDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
value - The replacement text of the entity.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
externalEntityDecl(java.lang.String, java.lang.String, java.lang.String), DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

externalEntityDecl

public void externalEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId)
                        throws org.xml.sax.SAXException
Report a parsed external entity declaration.

Only the effective (first) declaration for each entity will be reported.

Specified by:
externalEntityDecl in interface org.xml.sax.ext.DeclHandler

Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
publicId - The declared public identifier of the entity, or null if none was declared.
systemId - The declared system identifier of the entity.
Throws:
org.xml.sax.SAXException - The application may raise an exception.
See Also:
internalEntityDecl(java.lang.String, java.lang.String), DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

accumDefaultEntity

protected int accumDefaultEntity(char ch,
                                 int i,
                                 char[] chars,
                                 int len,
                                 boolean escLF)
                          throws org.xml.sax.SAXException
Handle one of the default entities, return false if it is not a default entity.

Parameters:
ch - character to be escaped.
i - index into character array.
chars - non-null reference to character array.
len - length of chars.
escLF - true if the linefeed should be escaped.
Returns:
i+1 if the character was written, else i.
Throws:
org.xml.sax.SAXException -  

accumDefaultEscape

protected int accumDefaultEscape(char ch,
                                 int i,
                                 char[] chars,
                                 int len,
                                 boolean escLF)
                          throws org.xml.sax.SAXException
Escape and m_writer.write a character.

Parameters:
ch - character to be escaped.
i - index into character array.
chars - non-null reference to character array.
len - length of chars.
escLF - true if the linefeed should be escaped.
Returns:
i+1 if the character was written, else i.
Throws:
org.xml.sax.SAXException -  

canConvert

public boolean canConvert(char ch)
Tell if this character can be written without escaping.


writeAttrString

public void writeAttrString(java.lang.String string,
                            java.lang.String encoding)
                     throws org.xml.sax.SAXException
Returns the specified string after substituting specials, and UTF-16 surrogates for chracter references &#xnn.

Parameters:
string - String to convert to XML format.
encoding - CURRENTLY NOT IMPLEMENTED.
Throws:
org.xml.sax.SAXException -  

shouldIndent

protected boolean shouldIndent()
Tell if, based on space preservation constraints and the doIndent property, if an indent should occur.

Returns:
True if an indent should occur.

printSpace

public void printSpace(int n)
                throws org.xml.sax.SAXException
Prints n spaces.

Parameters:
pw - The character output stream to use.
n - Number of spaces to print.
Throws:
org.xml.sax.SAXException - if an error occurs when writing.

indent

public void indent(int n)
            throws org.xml.sax.SAXException
Prints a newline character and n spaces.

Parameters:
pw - The character output stream to use.
n - Number of spaces to print.
Throws:
org.xml.sax.SAXException - if an error occurs during writing.

setOutputStream

public void setOutputStream(java.io.OutputStream output)
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified in the output properties is used, or if no encoding was specified, the default for the selected output method.

Specified by:
setOutputStream in interface Serializer

Parameters:
output - The output stream

getOutputStream

public java.io.OutputStream getOutputStream()
Get the output stream where the events will be serialized to.
Specified by:
getOutputStream in interface Serializer

Returns:
reference to the result stream, or null of only a writer was set.

setWriter

public void setWriter(java.io.Writer writer)
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.
Specified by:
setWriter in interface Serializer

Parameters:
writer - The output writer stream

getWriter

public java.io.Writer getWriter()
Get the character stream where the events will be serialized to.
Specified by:
getWriter in interface Serializer

Returns:
Reference to the result Writer, or null.

setOutputFormat

public void setOutputFormat(java.util.Properties format)
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document.
Specified by:
setOutputFormat in interface Serializer

Parameters:
format - The output format to use

getOutputFormat

public java.util.Properties getOutputFormat()
Returns the output format for this serializer.
Specified by:
getOutputFormat in interface Serializer

Returns:
The output format in use

asContentHandler

public org.xml.sax.ContentHandler asContentHandler()
                                            throws java.io.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:
java.io.IOException - An I/O exception occured

asDOMSerializer

public DOMSerializer asDOMSerializer()
                              throws java.io.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:
java.io.IOException - An I/O exception occured

reset

public boolean reset()
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 use the existing output format and output stream.
Specified by:
reset in interface Serializer

Returns:
True if serializer has been reset and can be reused

serialize

public void serialize(org.w3c.dom.Node node)
               throws java.io.IOException
Serializes the DOM node. Throws an exception only if an I/O exception occured while serializing.
Specified by:
serialize in interface DOMSerializer

Parameters:
elem - The element to serialize
node - Node to serialize.
Throws:
java.io.IOException - An I/O exception occured while serializing

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs70

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.
WebLogic Server 7.0 API Reference