public class ReceivingContentHandler extends Object implements ContentHandler, LexicalHandler, DTDHandler
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.
The ReceivingContentHandler is written on the assumption that it is receiving events
from a parser configured with http://xml.org/sax/features/namespaces set to true
and http://xml.org/sax/features/namespace-prefixes set to false.
When running as a TransformerHandler, we have no control over the feature settings
of the sender of the events, and if the events do not follow this pattern then the class may
fail in unpredictable ways.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReceivingContentHandler.LocalLocator
An implementation of the Saxon
Location interface that wraps the SAX Locator
information. |
| Constructor and Description |
|---|
ReceivingContentHandler()
Create a ReceivingContentHandler and initialise variables
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Report character data.
|
void |
comment(char[] ch,
int start,
int length)
Notify the existence of a comment.
|
void |
endCDATA() |
void |
endDocument()
Receive notification of the end of a document
|
void |
endDTD()
Register the end of the DTD.
|
void |
endElement(String uri,
String localname,
String rawname)
Report the end of an element (the close tag)
|
void |
endEntity(String name) |
void |
endPrefixMapping(String prefix)
Notify that a namespace binding is going out of scope
|
Configuration |
getConfiguration()
Get the Configuration object
|
PipelineConfiguration |
getPipelineConfiguration()
Get the pipeline configuration
|
Receiver |
getReceiver()
Get the receiver to which events are passed.
|
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
|
boolean |
isIgnoringIgnorableWhitespace()
Determine whether "ignorable whitespace" is ignored.
|
void |
notationDecl(String name,
String publicId,
String systemId) |
void |
processingInstruction(String name,
String remainder)
Notify the existence of a processing instruction
|
void |
reset()
Set the ReceivingContentHandler to its initial state, except for the local name cache,
which is retained
|
void |
setDocumentLocator(Locator locator)
Supply a locator that can be called to give information about location in the source document
being parsed.
|
void |
setIgnoreIgnorableWhitespace(boolean ignore)
Set whether "ignorable whitespace" should be ignored.
|
void |
setPipelineConfiguration(PipelineConfiguration pipe)
Set the pipeline configuration
|
void |
setReceiver(Receiver receiver)
Set the receiver to which events are passed.
|
void |
skippedEntity(String name)
Notify a skipped entity.
|
void |
startCDATA() |
void |
startDocument()
Receive notification of the beginning of a document.
|
void |
startDTD(String name,
String publicId,
String systemId)
Register the start of the DTD.
|
void |
startElement(String uri,
String localname,
String rawname,
Attributes atts)
Receive notification of the beginning of an element.
|
void |
startEntity(String name) |
void |
startPrefixMapping(String prefix,
String uri)
Notify a namespace prefix to URI binding
|
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName) |
public ReceivingContentHandler()
public void reset()
public void setReceiver(Receiver receiver)
receiver - the Receiver of eventspublic Receiver getReceiver()
public void setPipelineConfiguration(PipelineConfiguration pipe)
pipe - the pipeline configuration. This holds a reference to the Saxon configuration, as well as
information that can vary from one pipeline to anotherpublic PipelineConfiguration getPipelineConfiguration()
setPipelineConfiguration(PipelineConfiguration)public Configuration getConfiguration()
public void setIgnoreIgnorableWhitespace(boolean ignore)
ignore - true if ignorable whitespace (whitespace in element content that is notified
via the ignorableWhitespace(char[], int, int) method) should be ignored, false if
it should be treated as ordinary text.public boolean isIgnoringIgnorableWhitespace()
setIgnoreIgnorableWhitespace(boolean) if that has been called; otherwise the value
from the configuration.public void startDocument()
throws SAXException
startDocument in interface ContentHandlerSAXExceptionpublic void endDocument()
throws SAXException
endDocument in interface ContentHandlerSAXExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlerpublic void startPrefixMapping(String prefix, String uri)
startPrefixMapping in interface ContentHandlerpublic void endPrefixMapping(String prefix)
endPrefixMapping in interface ContentHandlerpublic void startElement(String uri, String localname, String rawname, Attributes atts) throws SAXException
The Parser will invoke this method at the beginning of every
element in the XML document; there will be a corresponding
endElement event for every startElement event
(even when the element is empty). All of the element's content will be
reported, in order, before the corresponding endElement
event.
This event allows up to three name components for each element:
Saxon expects all three of these to be provided.
The attribute list provided should contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes should be omitted. The attribute list should not contain attributes used for Namespace declarations (xmlns* attributes); if it does, Saxon will ignore them, which may lead to unresolved namespace prefixes.
startElement in interface ContentHandleruri - the Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performedlocalname - the local name (without prefix), or the
empty string if Namespace processing is not being
performedrawname - the qualified name (with prefix), or the
empty string if qualified names are not availableatts - the attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. The value of this object after
startElement returns is undefinedSAXException - any SAX exception, possibly
wrapping another exceptionendElement(java.lang.String, java.lang.String, java.lang.String),
Attributes,
AttributesImplpublic void endElement(String uri, String localname, String rawname) throws SAXException
endElement in interface ContentHandlerSAXExceptionpublic void characters(char[] ch,
int start,
int length)
characters in interface ContentHandlerpublic void ignorableWhitespace(char[] ch,
int start,
int length)
ignorableWhitespace in interface ContentHandlerpublic void processingInstruction(String name, String remainder) throws SAXException
processingInstruction in interface ContentHandlerSAXExceptionpublic void comment(char[] ch,
int start,
int length)
throws SAXException
comment in interface LexicalHandlerSAXExceptionpublic void skippedEntity(String name)
skippedEntity in interface ContentHandlerpublic void startDTD(String name, String publicId, String systemId)
startDTD in interface LexicalHandlerpublic void endDTD()
endDTD in interface LexicalHandlerpublic void startEntity(String name)
startEntity in interface LexicalHandlerpublic void endEntity(String name)
endEntity in interface LexicalHandlerpublic void startCDATA()
startCDATA in interface LexicalHandlerpublic void endCDATA()
endCDATA in interface LexicalHandlerpublic void notationDecl(String name, String publicId, String systemId)
notationDecl in interface DTDHandlerpublic void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
unparsedEntityDecl in interface DTDHandlerSAXException