net.sf.saxon.event

Class ReceivingContentHandler

public class ReceivingContentHandler extends Object implements ContentHandler, LexicalHandler, DTDHandler

ReceivingContentHandler is a glue class that provides a standard SAX ContentHandler interface to a Saxon Receiver. To achieve this it needs to map names supplied as strings to numeric name codes, for which purpose it needs access to a name pool. The class also performs the function of assembling adjacent text nodes.

The class was previously named ContentEmitter.

If the input stream contains the processing instructions assigned by JAXP to switch disable-output-escaping on or off, these will be reflected in properties set in the corresponding characters events. In this case adjacent text nodes will not be combined.

Author: Michael H. Kay

Constructor Summary
ReceivingContentHandler()
Create a ReceivingContentHandler and initialise variables
Method Summary
voidcharacters(char[] ch, int start, int length)
Report character data.
voidcomment(char[] ch, int start, int length)
Notify the existence of a comment.
voidendCDATA()
voidendDocument()
Receive notification of the end of a document
voidendDTD()
Register the end of the DTD.
voidendElement(String uri, String localname, String rawname)
Report the end of an element (the close tag)
voidendEntity(String name)
voidendPrefixMapping(String prefix)
Notify that a namespace binding is going out of scope
ConfigurationgetConfiguration()
Get the Configuration object
PipelineConfigurationgetPipelineConfiguration()
Get the pipeline configuration
voidignorableWhitespace(char[] ch, int start, int length)
Report character data classified as "Ignorable whitespace", that is, whitespace text nodes appearing as children of elements with an element-only content model
booleanisIgnoringIgnorableWhitespace()
Determine whether "ignorable whitespace" is ignored.
voidnotationDecl(String name, String publicId, String systemId)
voidprocessingInstruction(String name, String remainder)
Notify the existence of a processing instruction
voidreset()
Set the ReceivingContentHandler to its initial state, except for the local name cache, which is retained
voidsetDocumentLocator(Locator locator)
Supply a locator that can be called to give information about location in the source document being parsed.
voidsetIgnoreIgnorableWhitespace(boolean ignore)
Set whether "ignorable whitespace" should be ignored.
voidsetPipelineConfiguration(PipelineConfiguration pipe)
Set the pipeline configuration
voidsetReceiver(Receiver receiver)
Set the receiver to which events are passed.
voidskippedEntity(String name)
Notify a skipped entity.
voidstartCDATA()
voidstartDocument()
Receive notification of the beginning of a document.
voidstartDTD(String name, String publicId, String systemId)
Register the start of the DTD.
voidstartElement(String uri, String localname, String rawname, Attributes atts)
Notify an element start event, including all the associated attributes
voidstartEntity(String name)
voidstartPrefixMapping(String prefix, String uri)
Notify a namespace prefix to URI binding
voidunparsedEntityDecl(String name, String publicId, String systemId, String notationName)

Constructor Detail

ReceivingContentHandler

public ReceivingContentHandler()
Create a ReceivingContentHandler and initialise variables

Method Detail

characters

public void characters(char[] ch, int start, int length)
Report character data. Note that contiguous character data may be reported as a sequence of calls on this method, with arbitrary boundaries

comment

public void comment(char[] ch, int start, int length)
Notify the existence of a comment. Note that in SAX this is part of LexicalHandler interface rather than the ContentHandler interface.

endCDATA

public void endCDATA()

endDocument

public void endDocument()
Receive notification of the end of a document

endDTD

public void endDTD()
Register the end of the DTD. Comments in the DTD are skipped because they are not part of the XPath data model

endElement

public void endElement(String uri, String localname, String rawname)
Report the end of an element (the close tag)

endEntity

public void endEntity(String name)

endPrefixMapping

public void endPrefixMapping(String prefix)
Notify that a namespace binding is going out of scope

getConfiguration

public Configuration getConfiguration()
Get the Configuration object

Returns: the Saxon configuration

getPipelineConfiguration

public PipelineConfiguration getPipelineConfiguration()
Get the pipeline configuration

Returns: the pipeline configuration as supplied to setPipelineConfiguration

ignorableWhitespace

public void ignorableWhitespace(char[] ch, int start, int length)
Report character data classified as "Ignorable whitespace", that is, whitespace text nodes appearing as children of elements with an element-only content model

isIgnoringIgnorableWhitespace

public boolean isIgnoringIgnorableWhitespace()
Determine whether "ignorable whitespace" is ignored. This returns the value that was set using ReceivingContentHandler if that has been called; otherwise the value from the configuration.

Returns: true if ignorable whitespace is being ignored

notationDecl

public void notationDecl(String name, String publicId, String systemId)

processingInstruction

public void processingInstruction(String name, String remainder)
Notify the existence of a processing instruction

reset

public void reset()
Set the ReceivingContentHandler to its initial state, except for the local name cache, which is retained

setDocumentLocator

public void setDocumentLocator(Locator locator)
Supply a locator that can be called to give information about location in the source document being parsed.

setIgnoreIgnorableWhitespace

public void setIgnoreIgnorableWhitespace(boolean ignore)
Set whether "ignorable whitespace" should be ignored. This method is effective only if called after setPipelineConfiguration, since the default value is taken from the configuration.

Parameters: ignore true if ignorable whitespace (whitespace in element content that is notified via the (char[], int, int) method) should be ignored, false if it should be treated as ordinary text.

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration pipe)
Set the pipeline configuration

Parameters: pipe the pipeline configuration. This holds a reference to the Saxon configuration, as well as information that can vary from one pipeline to another, for example the LocationProvider which resolves the location of events in a source document

setReceiver

public void setReceiver(Receiver receiver)
Set the receiver to which events are passed. ReceivingContentHandler is essentially a translator that takes SAX events as input and produces Saxon Receiver events as output; these Receiver events are passed to the supplied Receiver

Parameters: receiver the Receiver of events

skippedEntity

public void skippedEntity(String name)
Notify a skipped entity. Saxon ignores this event

startCDATA

public void startCDATA()

startDocument

public void startDocument()
Receive notification of the beginning of a document.

startDTD

public void startDTD(String name, String publicId, String systemId)
Register the start of the DTD. Saxon ignores the DTD; however, it needs to know when the DTD starts and ends so that it can ignore comments in the DTD, which are reported like any other comment, but which are skipped because they are not part of the XPath data model

startElement

public void startElement(String uri, String localname, String rawname, Attributes atts)
Notify an element start event, including all the associated attributes

startEntity

public void startEntity(String name)

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)
Notify a namespace prefix to URI binding

unparsedEntityDecl

public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)