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
Method Summary |
void | attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
Notify an attribute. |
void | characters(CharSequence chars, int locationId, int properties)
Character data |
void | close()
End of document |
void | comment(CharSequence chars, int locationId, int properties)
Output a comment. |
void | endDocument()
Notify the end of a document node |
void | endElement()
End of element |
int | getColumnNumber()
Get the column number |
int | getLineNumber()
Get the line number |
String | getPublicId()
Get the Public ID |
String | getSystemId()
Get the System ID |
ContentHandler | getUnderlyingContentHandler()
Get the underlying content handler |
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. |
boolean | isUndeclareNamespaces()
Determine whether namespace undeclaration events (for a non-null prefix) should be notified.
|
void | namespace(int namespaceCode, int properties)
Notify a namespace. |
protected void | notifyNotWellFormed()
The following function is called when it is found that the output is not a well-formed document.
|
void | open()
Start of document |
void | processingInstruction(String target, CharSequence data, int locationId, int properties)
Processing Instruction |
void | setLexicalHandler(LexicalHandler handler)
Set the Lexical Handler to be used. |
void | setOutputProperties(Properties details)
Set the output details. |
void | setPipelineConfiguration(PipelineConfiguration config)
Set the pipeline configuration |
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 | setUndeclareNamespaces(boolean undeclareNamespaces)
Determine whether namespace undeclaration events (for a non-null prefix) should be notified.
|
void | setUnderlyingContentHandler(ContentHandler handler)
Set the underlying content handler. |
void | startContent()
Notify the start of the content, that is, the completion of all attributes and namespaces.
|
void | startDocument(int properties)
Start of a document node. |
void | startElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element |
protected ContentHandler handler
protected LexicalHandler lexicalHandler
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.
public void characters(CharSequence chars, int locationId, int properties)
Character data
public void close()
End of document
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.
public void endDocument()
Notify the end of a document node
public void endElement()
End of element
public int getColumnNumber()
Get the column number
Returns: -1 (always)
public int getLineNumber()
Get the line number
Returns: the line number giving the location of the most recent event notified
public String getPublicId()
Get the Public ID
Returns: null (always)
public String getSystemId()
Get the System ID
Returns: the system ID giving the location of the most recent event notified
public ContentHandler getUnderlyingContentHandler()
Get the underlying content handler
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.
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
public void namespace(int namespaceCode, int properties)
Notify a namespace. Namespaces are notified after the startElement event, and before
any children for the element.
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.
public void open()
Start of document
public void processingInstruction(String target, CharSequence data, int locationId, int properties)
Processing Instruction
public void setLexicalHandler(LexicalHandler handler)
Set the Lexical Handler to be used. If called, this must be called AFTER
setUnderlyingContentHandler()
public void setOutputProperties(Properties details)
Set the output details.
Set the pipeline configuration
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.
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
public void setUnderlyingContentHandler(ContentHandler handler)
Set the underlying content handler. This call is mandatory before using the Emitter.
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.
public void startDocument(int properties)
Start of a document node.
public void startElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element