com.icl.saxon.output
Class ContentHandlerProxy

java.lang.Object
  |
  +--com.icl.saxon.output.ContentHandlerProxy
All Implemented Interfaces:
Emitter
Direct Known Subclasses:
FOPEmitter

public class ContentHandlerProxy
extends java.lang.Object
implements Emitter

A ContentHandlerProxy is an Emitter that filters data before passing it to an underlying SAX2 ContentHandler. Note that in general the output passed to an Emitter corresponds to an External General Parsed Entity. A SAX2 ContentHandler only expects to deal with well-formed XML documents, so we only pass it the contents of the first element encountered.


Field Summary
protected  org.xml.sax.helpers.AttributesImpl attributes
           
protected  CharacterSet characterSet
           
protected  org.xml.sax.ContentHandler handler
           
protected  org.xml.sax.ext.LexicalHandler lexicalHandler
           
protected  NamePool namePool
           
protected  OutputDetails outputDetails
           
protected  boolean requireWellFormed
           
protected  java.io.Writer writer
           
 
Constructor Summary
ContentHandlerProxy()
           
 
Method Summary
 void characters(char[] chars, int start, int len)
          Character data
 void comment(char[] ch, int start, int length)
          Output a comment.
 void endDocument()
          End of document
 void endElement(int nameCode)
          End of element
 void ignorableWhitespace(char[] chars, int start, int len)
          Ignorable Whitespace
 void processingInstruction(java.lang.String target, java.lang.String data)
          Processing Instruction
 void setCharacterSet(CharacterSet charset)
          Set the CharacterSet to be used.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Set Document Locator
 void setEscaping(boolean escaping)
          Switch escaping on or off.
 void setIndenting(boolean indenting)
          Set indenting on or off
 void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
          Set the Lexical Handler to be used.
 void setNamePool(NamePool pool)
          Set the name pool to be used for all name codes
 void setOutputDetails(OutputDetails details)
          Set output details
 void setRequireWellFormed(boolean wellFormed)
          Indicate whether the content handler can handle a stream of events that is merely well-balanced, or whether it can only handle a well-formed sequence.
 void setUnderlyingContentHandler(org.xml.sax.ContentHandler handler)
          Set the underlying content handler.
 void setUnparsedEntity(java.lang.String name, java.lang.String uri)
          Set the URI for an unparsed entity in the document.
 void setWriter(java.io.Writer writer)
          Set the Writer to be used.
 void startDocument()
          Start of document
 void startElement(int nameCode, org.xml.sax.Attributes atts, int[] namespaces, int nscount)
          Start of element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namePool

protected NamePool namePool

handler

protected org.xml.sax.ContentHandler handler

lexicalHandler

protected org.xml.sax.ext.LexicalHandler lexicalHandler

writer

protected java.io.Writer writer

characterSet

protected CharacterSet characterSet

outputDetails

protected OutputDetails outputDetails

attributes

protected org.xml.sax.helpers.AttributesImpl attributes

requireWellFormed

protected boolean requireWellFormed
Constructor Detail

ContentHandlerProxy

public ContentHandlerProxy()
Method Detail

setNamePool

public void setNamePool(NamePool pool)
Set the name pool to be used for all name codes
Specified by:
setNamePool in interface Emitter

setUnderlyingContentHandler

public void setUnderlyingContentHandler(org.xml.sax.ContentHandler handler)
Set the underlying content handler. This call is mandatory before using the Emitter.

setLexicalHandler

public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
Set the Lexical Handler to be used. If called, this must be called AFTER setUnderlyingContentHandler()

setWriter

public void setWriter(java.io.Writer writer)
               throws org.xml.sax.SAXException
Set the Writer to be used. The writer will already be set up to perform any encoding requested. A writer will always be supplied before startDocument() is called.
Specified by:
setWriter in interface Emitter

setCharacterSet

public void setCharacterSet(CharacterSet charset)
                     throws org.xml.sax.SAXException
Set the CharacterSet to be used. The CharacterSet is a property of the encoding, it defines which characters are available in the output encoding. If no character set is supplied, the UnicodeCharacterSet should be assumed.
Specified by:
setCharacterSet in interface Emitter

setRequireWellFormed

public void setRequireWellFormed(boolean wellFormed)
Indicate whether the content handler can handle a stream of events that is merely well-balanced, or whether it can only handle a well-formed sequence.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Set Document Locator
Specified by:
setDocumentLocator in interface Emitter

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Start of document
Specified by:
startDocument in interface Emitter

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
End of document
Specified by:
endDocument in interface Emitter

startElement

public void startElement(int nameCode,
                         org.xml.sax.Attributes atts,
                         int[] namespaces,
                         int nscount)
                  throws org.xml.sax.SAXException
Start of element
Specified by:
startElement in interface Emitter
Following copied from interface: com.icl.saxon.output.Emitter
Parameters:
namespaces - Array of namespace codes identifying the namespace prefix/uri pairs associated with this element
nscount - Number of significant entries within namespaces array

endElement

public void endElement(int nameCode)
                throws org.xml.sax.SAXException
End of element
Specified by:
endElement in interface Emitter

characters

public void characters(char[] chars,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
Character data
Specified by:
characters in interface Emitter

ignorableWhitespace

public void ignorableWhitespace(char[] chars,
                                int start,
                                int len)
                         throws org.xml.sax.SAXException
Ignorable Whitespace

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Processing Instruction
Specified by:
processingInstruction in interface Emitter

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Output a comment. Passes it on to the ContentHandler provided that the ContentHandler is also a SAX2 LexicalHandler.
Specified by:
comment in interface Emitter

setEscaping

public void setEscaping(boolean escaping)
                 throws org.xml.sax.SAXException
Switch escaping on or off. This is called when the XSLT disable-output-escaping attribute is used to switch escaping on or off. It is not called for other sections of output (e.g. element names) where escaping is inappropriate.
Specified by:
setEscaping in interface Emitter

setIndenting

public void setIndenting(boolean indenting)
Set indenting on or off

setOutputDetails

public void setOutputDetails(OutputDetails details)
                      throws org.xml.sax.SAXException
Set output details
Specified by:
setOutputDetails in interface Emitter
Following copied from interface: com.icl.saxon.output.Emitter
Parameters:
details - The details of the required output

setUnparsedEntity

public void setUnparsedEntity(java.lang.String name,
                              java.lang.String uri)
                       throws org.xml.sax.SAXException
Set the URI for an unparsed entity in the document.
Specified by:
setUnparsedEntity in interface Emitter