Skip navigation links

Oracle® Database XML Java API Reference
11g Release 1 (11.1)

B28391-01


oracle.xml.parser.v2
Class XMLSAXSerializer

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by oracle.xml.parser.v2.XMLSAXSerializer

All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler

public class XMLSAXSerializer
extends DefaultHandler
implements LexicalHandler, DeclHandler

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 attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String mode, java.lang.String value)
          Report an attribute type declaration.
 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 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 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 externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Report a parsed external entity declaration.
 void flush()
          Flushes the output stream or print writer
 void internalEntityDecl(java.lang.String name, java.lang.String value)
          Report an internal entity declaration.
 void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Receive notification of a notation declaration.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void setDocumentLocator(Locator loc)
          Receive a Locator object for document events.
 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.
 void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
          Receive notification of an unparsed entity declaration.

 

Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, resolveEntity, skippedEntity, startPrefixMapping, 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

setDocumentLocator

public void setDocumentLocator(Locator loc)
Description copied from class: DefaultHandler
Receive a Locator object for document events.

By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler
Parameters:
loc - A locator for all SAX document events.
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator), Locator

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:
uri - 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.
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:
uri - 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.
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.

elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String model)
                 throws 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 parameter entities are fully resolved and all whitespace is removed,and will include the enclosing parentheses. Other normalization (such as removing redundant parentheses or simplifying occurrence indicators) is at the discretion of the parser.

Specified by:
elementDecl in interface DeclHandler
Parameters:
name - The element type name.
model - The content model as a normalized string.
Throws:
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 mode,
                          java.lang.String value)
                   throws 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", a parenthesized token group with the separator "|" and all whitespace removed, or the word "NOTATION" followed by a space followed by a parenthesized token group with all whitespace removed.

The value will be the value as reported to applications, appropriately normalized and with entity and character references expanded.

Specified by:
attributeDecl in interface DeclHandler
Parameters:
eName - The name of the associated element.
aName - The name of the attribute.
type - A string representing the attribute type.
mode - A string representing the attribute defaulting mode ("#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:
SAXException - The application may raise an exception.

internalEntityDecl

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

Only the effective (first) declaration for each entity will be reported. All parameter entities in the value will be expanded, but general entities will not.

Specified by:
internalEntityDecl in interface 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:
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 SAXException
Report a parsed external entity declaration.

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

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

Specified by:
externalEntityDecl in interface DeclHandler
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
publicId - The entity's public identifier, or null if none was given.
systemId - The entity's system identifier.
Throws:
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)

notationDecl

public void notationDecl(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws SAXException
Description copied from class: DefaultHandler
Receive notification of a notation declaration.

By default, do nothing. Application writers may override this method in a subclass if they wish to keep track of the notations declared in a document.

Specified by:
notationDecl in interface DTDHandler
Overrides:
notationDecl in class DefaultHandler
Parameters:
name - The notation name.
publicId - The notation public identifier, or null if not available.
systemId - The notation system identifier.
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(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId,
                               java.lang.String notationName)
                        throws SAXException
Description copied from class: DefaultHandler
Receive notification of an unparsed entity declaration.

By default, do nothing. Application writers may override this method in a subclass to keep track of the unparsed entities declared in a document.

Specified by:
unparsedEntityDecl in interface DTDHandler
Overrides:
unparsedEntityDecl in class DefaultHandler
Parameters:
name - The entity name.
publicId - The entity public identifier, or null if not available.
systemId - The entity system identifier.
notationName - 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)

Skip navigation links

Oracle® Database XML Java API Reference
11g Release 1 (11.1)

B28391-01


Copyright © 2003, 2007, Oracle. All rights reserved.