public class ReceivingContentHandler
extends java.lang.Object
implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.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(java.lang.String uri,
java.lang.String localname,
java.lang.String rawname)
Report the end of an element (the close tag)
|
void |
endEntity(java.lang.String name) |
void |
endPrefixMapping(java.lang.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(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId) |
void |
processingInstruction(java.lang.String name,
java.lang.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(org.xml.sax.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(java.lang.String name)
Notify a skipped entity.
|
void |
startCDATA() |
void |
startDocument()
Receive notification of the beginning of a document.
|
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Register the start of the DTD.
|
void |
startElement(java.lang.String uri,
java.lang.String localname,
java.lang.String rawname,
org.xml.sax.Attributes atts)
Receive notification of the beginning of an element.
|
void |
startEntity(java.lang.String name) |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
Notify a namespace prefix to URI binding
|
void |
unparsedEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.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 org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
startPrefixMapping
in interface org.xml.sax.ContentHandler
public void endPrefixMapping(java.lang.String prefix)
endPrefixMapping
in interface org.xml.sax.ContentHandler
public void startElement(java.lang.String uri, java.lang.String localname, java.lang.String rawname, org.xml.sax.Attributes atts) throws org.xml.sax.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 org.xml.sax.ContentHandler
uri
- 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 undefinedorg.xml.sax.SAXException
- any SAX exception, possibly
wrapping another exceptionendElement(java.lang.String, java.lang.String, java.lang.String)
,
Attributes
,
AttributesImpl
public void endElement(java.lang.String uri, java.lang.String localname, java.lang.String rawname) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
public void ignorableWhitespace(char[] ch, int start, int length)
ignorableWhitespace
in interface org.xml.sax.ContentHandler
public void processingInstruction(java.lang.String name, java.lang.String remainder) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
org.xml.sax.SAXException
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void skippedEntity(java.lang.String name)
skippedEntity
in interface org.xml.sax.ContentHandler
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
startDTD
in interface org.xml.sax.ext.LexicalHandler
public void endDTD()
endDTD
in interface org.xml.sax.ext.LexicalHandler
public void startEntity(java.lang.String name)
startEntity
in interface org.xml.sax.ext.LexicalHandler
public void endEntity(java.lang.String name)
endEntity
in interface org.xml.sax.ext.LexicalHandler
public void startCDATA()
startCDATA
in interface org.xml.sax.ext.LexicalHandler
public void endCDATA()
endCDATA
in interface org.xml.sax.ext.LexicalHandler
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
notationDecl
in interface org.xml.sax.DTDHandler
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws org.xml.sax.SAXException
unparsedEntityDecl
in interface org.xml.sax.DTDHandler
org.xml.sax.SAXException
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.