net.sf.saxon.event

Class ContentHandlerProxy

public class ContentHandlerProxy extends Emitter implements 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, unless the saxon:require-well-formed output property is set to "no".

This ContentHandlerProxy provides no access to type information. For a ContentHandler that makes type information available, see TypedContentHandler

Field Summary
protected ContentHandlerhandler
protected LexicalHandlerlexicalHandler
protected AttributeCollectionImplpendingAttributes
Method Summary
voidattribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
Notify an attribute.
voidcharacters(CharSequence chars, int locationId, int properties)
Character data
voidclose()
End of document
voidcomment(CharSequence chars, int locationId, int properties)
Output a comment.
voidendDocument()
Notify the end of a document node
voidendElement()
End of element
intgetColumnNumber()
Get the column number
intgetLineNumber()
Get the line number
StringgetPublicId()
Get the Public ID
StringgetSystemId()
Get the System ID
ContentHandlergetUnderlyingContentHandler()
Get the underlying content handler
booleanisRequireWellFormed()
Determine 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.
booleanisUndeclareNamespaces()
Determine whether namespace undeclaration events (for a non-null prefix) should be notified.
voidnamespace(int namespaceCode, int properties)
Notify a namespace.
protected voidnotifyNotWellFormed()
The following function is called when it is found that the output is not a well-formed document.
voidopen()
Start of document
voidprocessingInstruction(String target, CharSequence data, int locationId, int properties)
Processing Instruction
voidsetLexicalHandler(LexicalHandler handler)
Set the Lexical Handler to be used.
voidsetOutputProperties(Properties details)
Set the output details.
voidsetPipelineConfiguration(PipelineConfiguration config)
Set the pipeline configuration
voidsetRequireWellFormed(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.
voidsetUndeclareNamespaces(boolean undeclareNamespaces)
Determine whether namespace undeclaration events (for a non-null prefix) should be notified.
voidsetUnderlyingContentHandler(ContentHandler handler)
Set the underlying content handler.
voidstartContent()
Notify the start of the content, that is, the completion of all attributes and namespaces.
voidstartDocument(int properties)
Start of a document node.
voidstartElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element

Field Detail

handler

protected ContentHandler handler

lexicalHandler

protected LexicalHandler lexicalHandler

pendingAttributes

protected AttributeCollectionImpl pendingAttributes

Method Detail

attribute

public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
Notify an attribute. Attributes are notified after the startElement event, and before any children.

characters

public void characters(CharSequence chars, int locationId, int properties)
Character data

close

public void close()
End of document

comment

public void comment(CharSequence chars, int locationId, int properties)
Output a comment. Passes it on to the ContentHandler provided that the ContentHandler is also a SAX2 LexicalHandler.

endDocument

public void endDocument()
Notify the end of a document node

endElement

public void endElement()
End of element

getColumnNumber

public int getColumnNumber()
Get the column number

Returns: -1 (always)

getLineNumber

public int getLineNumber()
Get the line number

Returns: the line number giving the location of the most recent event notified

getPublicId

public String getPublicId()
Get the Public ID

Returns: null (always)

getSystemId

public String getSystemId()
Get the System ID

Returns: the system ID giving the location of the most recent event notified

getUnderlyingContentHandler

public ContentHandler getUnderlyingContentHandler()
Get the underlying content handler

isRequireWellFormed

public boolean isRequireWellFormed()
Determine 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.

isUndeclareNamespaces

public boolean isUndeclareNamespaces()
Determine whether namespace undeclaration events (for a non-null prefix) should be notified. The default is no, because some ContentHandlers (e.g. JDOM) can't cope with them.

Returns: true if namespace undeclarations (xmlns:p="") are output

namespace

public void namespace(int namespaceCode, int properties)
Notify a namespace. Namespaces are notified after the startElement event, and before any children for the element.

notifyNotWellFormed

protected void notifyNotWellFormed()
The following function is called when it is found that the output is not a well-formed document. Unless the ContentHandler accepts "balanced content", this is a fatal error.

open

public void open()
Start of document

processingInstruction

public void processingInstruction(String target, CharSequence data, int locationId, int properties)
Processing Instruction

setLexicalHandler

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

setOutputProperties

public void setOutputProperties(Properties details)
Set the output details.

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration config)
Set the pipeline configuration

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.

setUndeclareNamespaces

public void setUndeclareNamespaces(boolean undeclareNamespaces)
Determine whether namespace undeclaration events (for a non-null prefix) should be notified. The default is no, because some ContentHandlers (e.g. JDOM) can't cope with them.

Parameters: undeclareNamespaces true if namespace undeclarations (xmlns:p="") are to be output

setUnderlyingContentHandler

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

startContent

public void startContent()
Notify the start of the content, that is, the completion of all attributes and namespaces. Note that the initial receiver of output from XSLT instructions will not receive this event, it has to detect it itself. Note that this event is reported for every element even if it has no attributes, no namespaces, and no content.

startDocument

public void startDocument(int properties)
Start of a document node.

startElement

public void startElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element