Oracle® XML Java API Reference
Release 1 (10.1)

B12024-01

oracle.xml.parser.v2
Class XMLSAXSerializer

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--oracle.xml.parser.v2.XMLSAXSerializer
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler

public class XMLSAXSerializer
extends DefaultHandler
implements LexicalHandler

Class to print the document based on SAX Events


Field Summary
static java.lang.String ENCODING
          Output encoding property
static java.lang.String INDENT
          Output Indenting
static java.lang.String OMIT_XML_DECL
          Print XML Declaration

 

Constructor Summary
XMLSAXSerializer(java.io.OutputStream os)
          Create a XMLSAXSerializer to print the XML to the given OutputStream
XMLSAXSerializer(java.io.PrintWriter pw)
          Create a XMLSAXSerializer to print the XML to the given PrintWriter

 

Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data inside an element.
 void comment(char[] ch, int start, int length)
          Report an XML comment anywhere in the document.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Receive notification of the end of the document.
 void endDTD()
          Report the end of DTD declarations.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element.
 void endEntity(java.lang.String name)
          Report the end of an entity.
 void flush()
          Flushes the output stream or print writer
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void setProperty(java.lang.String property, java.lang.Object value)
          Set output printing properties
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Receive notification of the beginning of the 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 qName, Attributes atts)
          Receive notification of the beginning of an element.
 void startEntity(java.lang.String name)
          Report the beginning of some internal and external XML entities.

 

Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

ENCODING

public static final java.lang.String ENCODING
Output encoding property
See Also:
setProperty(java.lang.String, java.lang.Object), Constant Field Values

INDENT

public static final java.lang.String INDENT
Output Indenting
See Also:
setProperty(java.lang.String, java.lang.Object), Constant Field Values

OMIT_XML_DECL

public static final java.lang.String OMIT_XML_DECL
Print XML Declaration
See Also:
setProperty(java.lang.String, java.lang.Object), Constant Field Values
Constructor Detail

XMLSAXSerializer

public XMLSAXSerializer(java.io.PrintWriter pw)
Create a XMLSAXSerializer to print the XML to the given PrintWriter
Parameters:
pw - PrintWriter

XMLSAXSerializer

public XMLSAXSerializer(java.io.OutputStream os)
Create a XMLSAXSerializer to print the XML to the given OutputStream
Parameters:
os - OutputStream
Method Detail

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
Set output printing properties
Parameters:
property -
value - of the property

flush

public void flush()
           throws java.io.IOException
Flushes the output stream or print writer
Throws:
java.io.IOException

startDocument

public void startDocument()
                   throws SAXException
Receive notification of the beginning of the document.
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws SAXException
Receive notification of the end of the document.
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
Attributes atts)
                  throws SAXException
Receive notification of the beginning of an element.
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Parameters:
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
atts - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
endElement(java.lang.String, java.lang.String, java.lang.String), Attributes

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws SAXException
Receive notification of the end of an element.
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Parameters:
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws SAXException
Receive notification of a processing instruction.
Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none is supplied.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.processingInstruction(java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Receive notification of character data inside an element.
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.characters(char[], int, int)

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws SAXException
Report the start of DTD declarations, if any.
Specified by:
startDTD in interface 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:
SAXException - The application may raise an exception.
See Also:
endDTD(), startEntity(java.lang.String)

endDTD

public void endDTD()
            throws SAXException
Report the end of DTD declarations.

This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)

startEntity

public void startEntity(java.lang.String name)
                 throws SAXException
Report the beginning of some internal and external XML entities.
Specified by:
startEntity in interface LexicalHandler
Parameters:
name - The name of the entity.
Throws:
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 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:
startEntity(java.lang.String)

startCDATA

public void startCDATA()
                throws SAXException
Report the start of a CDATA section.

The contents of the CDATA section will be reported through the regular characters event; this event is intended only to report the boundary.

Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
endCDATA()

endCDATA

public void endCDATA()
              throws SAXException
Report the end of a CDATA section.
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
startCDATA()

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Report an XML comment anywhere in the document.
Specified by:
comment in interface 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:
SAXException - The application may raise an exception.

Oracle® XML Java API Reference
Release 1 (10.1)

B12024-01

Copyright © 2003, Oracle. All Rights Reserved.