Package com.icl.saxon.output
Class ContentHandlerProxy
- java.lang.Object
-
- com.icl.saxon.output.Emitter
-
- com.icl.saxon.output.ContentHandlerProxy
-
- All Implemented Interfaces:
javax.xml.transform.Result,org.xml.sax.Locator
public class ContentHandlerProxy extends Emitter implements org.xml.sax.Locator
A ContentHandlerProxy is an Emitter that filters data before passing it to an underlying SAX2 ContentHandler. Relevant events (notably comments) can also be fed to a LexicalHandler. 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
Fields Modifier and Type Field Description protected org.xml.sax.ContentHandlerhandlerprotected org.xml.sax.ext.LexicalHandlerlexicalHandlerprotected org.xml.sax.Locatorlocatorprotected booleanrequireWellFormed-
Fields inherited from class com.icl.saxon.output.Emitter
namePool, outputProperties, outputStream, systemId, writer
-
-
Constructor Summary
Constructors Constructor Description ContentHandlerProxy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] chars, int start, int len)Character datavoidcomment(char[] ch, int start, int length)Output a comment.voidendDocument()End of documentvoidendElement(int nameCode)End of elementintgetColumnNumber()intgetLineNumber()java.lang.StringgetPublicId()protected voidnotifyNotWellFormed()The following function notifies the content handler, by means of a processing instruction, that the output is not a well-formed document.voidprocessingInstruction(java.lang.String target, java.lang.String data)Processing InstructionvoidsetDocumentLocator(org.xml.sax.Locator locator)Set Document LocatorvoidsetEscaping(boolean escaping)Switch escaping on or off.voidsetLexicalHandler(org.xml.sax.ext.LexicalHandler handler)Set the Lexical Handler to be used.voidsetOutputProperties(java.util.Properties props)Set the output propertiesvoidsetRequireWellFormed(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.voidsetUnderlyingContentHandler(org.xml.sax.ContentHandler handler)Set the underlying content handler.voidstartDocument()Start of documentvoidstartElement(int nameCode, org.xml.sax.Attributes atts, int[] namespaces, int nscount)Start of element-
Methods inherited from class com.icl.saxon.output.Emitter
getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, setNamePool, setOutputStream, setSystemId, setUnparsedEntity, setWriter, usesWriter
-
-
-
-
Method Detail
-
setUnderlyingContentHandler
public void setUnderlyingContentHandler(org.xml.sax.ContentHandler handler)
Set the underlying content handler. This call is mandatory before using the Emitter.
-
setOutputProperties
public void setOutputProperties(java.util.Properties props)
Set the output properties- Overrides:
setOutputPropertiesin classEmitter
-
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()
-
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- Overrides:
setDocumentLocatorin classEmitter
-
startDocument
public void startDocument() throws javax.xml.transform.TransformerExceptionStart of document- Specified by:
startDocumentin classEmitter- Throws:
javax.xml.transform.TransformerException
-
endDocument
public void endDocument() throws javax.xml.transform.TransformerExceptionEnd of document- Specified by:
endDocumentin classEmitter- Throws:
javax.xml.transform.TransformerException
-
startElement
public void startElement(int nameCode, org.xml.sax.Attributes atts, int[] namespaces, int nscount) throws javax.xml.transform.TransformerExceptionStart of element- Specified by:
startElementin classEmitternamespaces- Array of namespace codes identifying the namespace prefix/uri pairs associated with this elementnscount- Number of significant entries within namespaces array- Throws:
javax.xml.transform.TransformerException
-
endElement
public void endElement(int nameCode) throws javax.xml.transform.TransformerExceptionEnd of element- Specified by:
endElementin classEmitter- Throws:
javax.xml.transform.TransformerException
-
characters
public void characters(char[] chars, int start, int len) throws javax.xml.transform.TransformerExceptionCharacter data- Specified by:
charactersin classEmitter- Throws:
javax.xml.transform.TransformerException
-
notifyNotWellFormed
protected void notifyNotWellFormed() throws org.xml.sax.SAXExceptionThe following function notifies the content handler, by means of a processing instruction, that the output is not a well-formed document. If the content handler responds with an exception containing the message "continue" (this is the only way it can get information back) then further events are notified, otherwise they are suppressed.- Throws:
org.xml.sax.SAXException
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws javax.xml.transform.TransformerExceptionProcessing Instruction- Specified by:
processingInstructionin classEmitter- Throws:
javax.xml.transform.TransformerException
-
comment
public void comment(char[] ch, int start, int length) throws javax.xml.transform.TransformerExceptionOutput a comment. Passes it on to the ContentHandler provided that the ContentHandler is also a SAX2 LexicalHandler.
-
setEscaping
public void setEscaping(boolean escaping)
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. The action, as defined in JAXP 1.1, is to notify the request to the Content Handler using a processing instruction.- Overrides:
setEscapingin classEmitter
-
getPublicId
public java.lang.String getPublicId()
- Specified by:
getPublicIdin interfaceorg.xml.sax.Locator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumberin interfaceorg.xml.sax.Locator
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumberin interfaceorg.xml.sax.Locator
-
-