Class ReceivingContentHandler
- java.lang.Object
-
- net.sf.saxon.event.ReceivingContentHandler
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.ext.LexicalHandler
- Direct Known Subclasses:
IdentityTransformerHandler,StreamingTransformerImpl.StreamingTransformerHandler,TemplatesHandlerImpl,TransformerHandlerImpl
public class ReceivingContentHandler extends java.lang.Object implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.DTDHandlerReceivingContentHandler 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.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
ReceivingContentHandleris written on the assumption that it is receiving events from a parser configured withhttp://xml.org/sax/features/namespacesset to true andhttp://xml.org/sax/features/namespace-prefixesset 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReceivingContentHandler.LocalLocatorAn implementation of the SaxonLocationinterface that wraps the SAX Locator information.
-
Constructor Summary
Constructors Constructor Description ReceivingContentHandler()Create a ReceivingContentHandler and initialise variables
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 documentvoidendDTD()Register the end of the DTD.voidendElement(java.lang.String uri, java.lang.String localname, java.lang.String rawname)Report the end of an element (the close tag)voidendEntity(java.lang.String name)voidendPrefixMapping(java.lang.String prefix)Notify that a namespace binding is going out of scopeConfigurationgetConfiguration()Get the Configuration objectPipelineConfigurationgetPipelineConfiguration()Get the pipeline configurationReceivergetReceiver()Get the receiver to which events are passed.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 modelbooleanisIgnoringIgnorableWhitespace()Determine whether "ignorable whitespace" is ignored.voidnotationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)voidprocessingInstruction(java.lang.String name, java.lang.String remainder)Notify the existence of a processing instructionvoidreset()Set the ReceivingContentHandler to its initial state, except for the local name cache, which is retainedvoidsetDocumentLocator(org.xml.sax.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 configurationvoidsetReceiver(Receiver receiver)Set the receiver to which events are passed.voidskippedEntity(java.lang.String name)Notify a skipped entity.voidstartCDATA()voidstartDocument()Receive notification of the beginning of a document.voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Register the start of the DTD.voidstartElement(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.voidstartEntity(java.lang.String name)voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)Notify a namespace prefix to URI bindingvoidunparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
-
-
-
Method Detail
-
reset
public void reset()
Set the ReceivingContentHandler to its initial state, except for the local name cache, which is retained
-
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
-
getReceiver
public Receiver getReceiver()
Get the receiver to which events are passed.- Returns:
- the underlying Receiver
-
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
-
getPipelineConfiguration
public PipelineConfiguration getPipelineConfiguration()
Get the pipeline configuration- Returns:
- the pipeline configuration as supplied to
setPipelineConfiguration(PipelineConfiguration)
-
getConfiguration
public Configuration getConfiguration()
Get the Configuration object- Returns:
- the Saxon configuration
-
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 theignorableWhitespace(char[], int, int)method) should be ignored, false if it should be treated as ordinary text.
-
isIgnoringIgnorableWhitespace
public boolean isIgnoringIgnorableWhitespace()
Determine whether "ignorable whitespace" is ignored. This returns the value that was set usingsetIgnoreIgnorableWhitespace(boolean)if that has been called; otherwise the value from the configuration.- Returns:
- true if ignorable whitespace is being ignored
-
startDocument
public void startDocument() throws org.xml.sax.SAXExceptionReceive notification of the beginning of a document.- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument() throws org.xml.sax.SAXExceptionReceive notification of the end of a document- Specified by:
endDocumentin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public 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.- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)Notify a namespace prefix to URI binding- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix)
Notify that a namespace binding is going out of scope- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler
-
startElement
public void startElement(java.lang.String uri, java.lang.String localname, java.lang.String rawname, org.xml.sax.Attributes atts) throws org.xml.sax.SAXExceptionReceive notification of the beginning of an element.The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding
endElementevent 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:
- the Namespace URI;
- the local name; and
- the qualified (prefixed) name.
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.
- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Parameters:
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 undefined- Throws:
org.xml.sax.SAXException- any SAX exception, possibly wrapping another exception- See Also:
endElement(java.lang.String, java.lang.String, java.lang.String),Attributes,AttributesImpl
-
endElement
public void endElement(java.lang.String uri, java.lang.String localname, java.lang.String rawname) throws org.xml.sax.SAXExceptionReport the end of an element (the close tag)- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
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- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler
-
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- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler
-
processingInstruction
public void processingInstruction(java.lang.String name, java.lang.String remainder) throws org.xml.sax.SAXExceptionNotify the existence of a processing instruction- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
comment
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXExceptionNotify the existence of a comment. Note that in SAX this is part of LexicalHandler interface rather than the ContentHandler interface.- Specified by:
commentin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
skippedEntity
public void skippedEntity(java.lang.String name)
Notify a skipped entity. Saxon ignores this event- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.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- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler
-
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- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler
-
startEntity
public void startEntity(java.lang.String name)
- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler
-
endEntity
public void endEntity(java.lang.String name)
- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler
-
startCDATA
public void startCDATA()
- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler
-
endCDATA
public void endCDATA()
- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler
-
notationDecl
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)- Specified by:
notationDeclin interfaceorg.xml.sax.DTDHandler
-
unparsedEntityDecl
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws org.xml.sax.SAXException- Specified by:
unparsedEntityDeclin interfaceorg.xml.sax.DTDHandler- Throws:
org.xml.sax.SAXException
-
-