Class XMLFilterImpl2
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler,DeclHandler,LexicalHandler,XMLFilter,XMLReader
- Direct Known Subclasses:
AncestorXMLFilter,CleanHouse,NormalizeSpace,WordInfilter62,XMLFilterImpl3
Provides an extensible class for filtering SAX events, including lexical events such as XML comments. The class is
functionally similar to XMLFilterImpl but provides additional extensible methods to support the
LexicalHandler and DeclHandler interfaces. The class name follows the naming
scheme used in the SAX 2.0.2 release, for the extended classes such as DefaultHandler2.
The default action of a method, unless overridden, is to copy input events to the output. In some respects this behaviour is similar to the XSLT identity transform.
This class will attempt to act as a LexicalHandler and DeclHandler but will silently ignore any SAXNotRecognizedException or SAXNotSupportedException thrown by the parent XMLReader when setting these properties. In this case it will act as if it were a standard XMLFilterImpl. When an XMLFilter produced by Saxon (and possibly by other XSLT processors) is followed by one extended from this class in a filter chain (PipelinedComparator input filters or JAXP) this is likely to be the case.
- Author:
- Nigel Whitaker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAn extensible implementation of the Declaration Handler attributeDecl event, which reports DTD related (external DTD or internal subset) attribute declarations.voidcomment(char[] ch, int start, int length) An extensible implementation of the SAX LexicalHandler comment event, which reports any comments identified by the parser.voidelementDecl(String name, String model) An extensible implementation of the Declaration Handler elementDecl event, which reports DTD related (external DTD or internal subset) element declarations.voidendCDATA()An extensible implementation of the SAX LexicalHandler endCDATA event, which reports the end of a CDATA boundry idenitified by the parser.voidendDTD()An extensible implementation of the SAX LexicalHandler endDTD event, which reports the end of DOCTYPE processing by the parser.voidAn extensible implementation of the SAX LexicalHandler endEntity event, which reports the end of entity instance processing by the parser.voidexternalEntityDecl(String name, String publicId, String systemId) An extensible implementation of the Declaration Handler externalEntityDecl event, which reports DTD related (external DTD or internal subset) external entity declarations.getProperty(String name) Reports a current property setting.voidinternalEntityDecl(String name, String value) An extensible implementation of the Declaration Handler intenalEntityDecl event, which reports DTD related (external DTD or internal subset) internal entity declarations.voidAn implementation of theXMLReader.parse(String)method.voidparse(InputSource source) An implementation of theXMLReader.parse(InputSource)method.voidsetProperty(String name, Object value) Specifies a property used to configure the filter.voidAn extensible implementation of the SAX LexicalHandler startCDATA event, which reports the start of a CDATA boundry idenitified by the parser.voidAn extensible implementation of the SAX LexicalHandler startDTD event, which reports the start of DOCTYPE processing by the parser.voidstartEntity(String name) An extensible implementation of the SAX LexicalHandler startEntity event, which reports the start of entity instance processing by the parser.Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
XMLFilterImpl2
public XMLFilterImpl2()Creates a new XMLFilterImpl2.
-
-
Method Details
-
parse
public void parse(InputSource source) throws SAXException, IOException, UnsupportedOperationException An implementation of the
XMLReader.parse(InputSource)method. This method when called can trigger a JAXP SAX-event passing pipeline. Alternatively it may be called indirectly (behind the scenes) by triggering another pipeline stage and then via thesetParentmethod the triggered stage will call this parse method.The behaviour of this method differs from that of the supertype
XMLFilterImpl.parse(InputSource)method in that it does not 'chain' the entityResolver from the parent. This allows an XMLReader at the start of a SAX filter pipeline to set and control its own entityResolver without interference from downstream filters. The behaviour of this class is also consistent with the behaviour of XMLFilters produced from Saxon B 9.1- Specified by:
parsein interfaceXMLReader- Overrides:
parsein classXMLFilterImpl- Parameters:
source- the data to be processed (by this stage, or initially by an upstream pipeline stage and passed to this stage as SAX events)- Throws:
SAXException- if the supertype throws this exceptionIOException- if the supertype throws this exceptionUnsupportedOperationException- if this method is called before configuring the pipeline with the setParent method- See Also:
-
parse
An implementation of theXMLReader.parse(String)method. This method when called can trigger a JAXP SAX-event passing pipeline. Alternatively it may be called indirectly (behind the scenes) by triggering another pipeline stage and then via thesetParentmethod the triggered stage will call this parse method.- Specified by:
parsein interfaceXMLReader- Overrides:
parsein classXMLFilterImpl- Parameters:
systemId- A URL which specifies the data to be processed (by this stage, or an upstream pipeline stage)- Throws:
SAXException- if the supertype throws this exceptionIOException- if the supertype throws this exceptionUnsupportedOperationException- if this method is called before configuring the pipeline with the setParent method- See Also:
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Specifies a property used to configure the filter. In addition to the property values typically supported by the standard (supertype) XMLFilterImpl this class also supports the following properties:- Specified by:
setPropertyin interfaceXMLReader- Overrides:
setPropertyin classXMLFilterImpl- Parameters:
name- the name of the property to be assignedvalue- the new value of the property- Throws:
SAXNotRecognizedException- if the feature name is not recognizedSAXNotSupportedException- if it is not possible to configure the feature with the specified value- See Also:
-
getProperty
Reports a current property setting. Properties are used to configure the filter behaviour. In addition to the property values typically supported by the standard (supertype) XMLFilterImpl this class also supports the following properties:- Specified by:
getPropertyin interfaceXMLReader- Overrides:
getPropertyin classXMLFilterImpl- Parameters:
name- the name of the property to be reported- Returns:
- an Object representation of the requested property
- Throws:
SAXNotRecognizedException- if the feature name is not recognizedSAXNotSupportedException- if it is not possible to determine the feature's value- See Also:
-
elementDecl
An extensible implementation of the Declaration Handler elementDecl event, which reports DTD related (external DTD or internal subset) element declarations. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
elementDeclin interfaceDeclHandler- Parameters:
name- The element name reportedmodel- The declaration content- Throws:
SAXException- if the supertype throws this exception- See Also:
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException An extensible implementation of the Declaration Handler attributeDecl event, which reports DTD related (external DTD or internal subset) attribute declarations. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
attributeDeclin interfaceDeclHandler- Parameters:
eName- The name of the element containing the attributeaName- The name of the attributetype- The type of the attributevalueDefault- The default value of the attribute, unless specified otherwisevalue- ????- Throws:
SAXException- if the supertype throws this exception- See Also:
-
internalEntityDecl
An extensible implementation of the Declaration Handler intenalEntityDecl event, which reports DTD related (external DTD or internal subset) internal entity declarations. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
internalEntityDeclin interfaceDeclHandler- Parameters:
name- The name of the entityvalue- The entity value- Throws:
SAXException- if the supertype throws this exception- See Also:
-
externalEntityDecl
An extensible implementation of the Declaration Handler externalEntityDecl event, which reports DTD related (external DTD or internal subset) external entity declarations. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
externalEntityDeclin interfaceDeclHandler- Parameters:
name- The name of the entitypublicId- A publicId which identifies the external entitysystemId- A systemId which locates the external entity- Throws:
SAXException- if the supertype throws this exception- See Also:
-
startDTD
An extensible implementation of the SAX LexicalHandler startDTD event, which reports the start of DOCTYPE processing by the parser. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
startDTDin interfaceLexicalHandler- Parameters:
name- The name of the root elementpublicId- The publicId of an external DTDsystemId- The systemId used to locate the external DTD- Throws:
SAXException- if the supertype throws this exception- See Also:
-
endDTD
An extensible implementation of the SAX LexicalHandler endDTD event, which reports the end of DOCTYPE processing by the parser. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException- if the supertype throws this exception- See Also:
-
startEntity
An extensible implementation of the SAX LexicalHandler startEntity event, which reports the start of entity instance processing by the parser. This method handles internal and external, general and parameter entities. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
startEntityin interfaceLexicalHandler- Parameters:
name- the name of the entity- Throws:
SAXException- if the supertype throws this exception- See Also:
-
endEntity
An extensible implementation of the SAX LexicalHandler endEntity event, which reports the end of entity instance processing by the parser. This method handles internal and external, general and parameter entities. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
endEntityin interfaceLexicalHandler- Parameters:
name- the name of the entity- Throws:
SAXException- if the supertype throws this exception- See Also:
-
startCDATA
An extensible implementation of the SAX LexicalHandler startCDATA event, which reports the start of a CDATA boundry idenitified by the parser. The actual CDATA content is reported by the character event. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException- if the supertype throws this exception- See Also:
-
endCDATA
An extensible implementation of the SAX LexicalHandler endCDATA event, which reports the end of a CDATA boundry idenitified by the parser. The actual CDATA content is reported by the character event. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException- if the supertype throws this exception- See Also:
-
comment
An extensible implementation of the SAX LexicalHandler comment event, which reports any comments identified by the parser. The actual CDATA content is reported by the character event. The default action of this filter method is to pass the parse event from input to output; it can be overriden to change this behaviour.- Specified by:
commentin interfaceLexicalHandler- Parameters:
ch- an array holding the comment amongst other character datastart- the starting position of this comment with the arraylength- the number of characters to use from the array- Throws:
SAXException- if the supertype throws this exception- See Also:
-