Class XMLFilter
Base class for deriving an XML filter.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
This class is designed to sit between an IXMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.
Inherited Members
Namespace: Sax.Helpers
Assembly: Lucene.Net.Benchmark.dll
Syntax
public class XMLFilter : IXMLFilter, IXMLReader, IEntityResolver, IDTDHandler, IContentHandler, IErrorHandler
Constructors
| Improve this Doc View SourceXMLFilter()
Construct an empty XML filter, with no parent.
This filter will have no parent: you must assign a parent before you start a parse or do any configuration with setFeature or setProperty, unless you use this as a pure event consumer rather than as an IXMLReader.
Declaration
public XMLFilter()
See Also
| Improve this Doc View SourceXMLFilter(IXMLReader)
Construct an XML filter with the specified parent.
Declaration
public XMLFilter(IXMLReader parent)
Parameters
| Type | Name | Description |
|---|---|---|
| IXMLReader | parent | The parent |
See Also
Properties
| Improve this Doc View SourceContentHandler
Gets or Sets the content event handler.
Declaration
public IContentHandler ContentHandler { get; set; }
Property Value
| Type | Description |
|---|---|
| IContentHandler |
DTDHandler
Gets or Sets the DTD event handler.
Declaration
public IDTDHandler DTDHandler { get; set; }
Property Value
| Type | Description |
|---|---|
| IDTDHandler |
EntityResolver
Gets or Sets the entity resolver.
Declaration
public IEntityResolver EntityResolver { get; set; }
Property Value
| Type | Description |
|---|---|
| IEntityResolver |
ErrorHandler
Gets or Sets the error event handler.
Declaration
public IErrorHandler ErrorHandler { get; set; }
Property Value
| Type | Description |
|---|---|
| IErrorHandler |
Parent
Gets or sets the parent reader.
Declaration
public IXMLReader Parent { get; set; }
Property Value
| Type | Description |
|---|---|
| IXMLReader |
Remarks
This is the IXMLReader from which this filter will obtain its events and to which it will pass its configuration requests. The parent may itself be another filter.
If there is no parent reader set, any attempt to parse or to set or get a feature or property will fail.
Methods
| Improve this Doc View SourceCharacters(Char[], Int32, Int32)
Filter a character data event.
Declaration
public virtual void Characters(char[] ch, int start, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char[] | ch | An array of characters. |
| System.Int32 | start | The starting position in the array. |
| System.Int32 | length | The number of characters to use from the array. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
EndDocument()
Filter an end document event.
Declaration
public virtual void EndDocument()
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
EndElement(String, String, String)
Filter an end element event.
Declaration
public virtual void EndElement(string uri, string localName, string qName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The element's Namespace URI, or the empty string. |
| System.String | localName | The element's local name, or the empty string. |
| System.String | qName | The element's qualified (prefixed) name, or the empty string. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
EndPrefixMapping(String)
Filter an end Namespace prefix mapping event.
Declaration
public virtual void EndPrefixMapping(string prefix)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | The Namespace prefix. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
Error(SAXParseException)
Filter an error event.
Declaration
public virtual void Error(SAXParseException e)
Parameters
| Type | Name | Description |
|---|---|---|
| SAXParseException | e | The error as an exception. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
FatalError(SAXParseException)
Filter a fatal error event.
Declaration
public virtual void FatalError(SAXParseException e)
Parameters
| Type | Name | Description |
|---|---|---|
| SAXParseException | e | The error as an exception. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
GetFeature(String)
Look up the value of a feature.
This will always fail if the parent is null.
Declaration
public virtual bool GetFeature(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The feature name. |
Returns
| Type | Description |
|---|---|
| System.Boolean | The current value of the feature. |
Exceptions
| Type | Condition |
|---|---|
| SAXNotRecognizedException | If the feature value can't be assigned or retrieved from the parent. |
| SAXNotSupportedException | When the parent recognizes the feature name but cannot determine its value at this time. |
GetProperty(String)
Look up the value of a property.
Declaration
public virtual object GetProperty(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The property name. |
Returns
| Type | Description |
|---|---|
| System.Object | The current value of the property. |
Exceptions
| Type | Condition |
|---|---|
| SAXNotRecognizedException | If the property value can't be assigned or retrieved from the parent. |
| SAXNotSupportedException | When the parent recognizes the property name but cannot determine its value at this time. |
IgnorableWhitespace(Char[], Int32, Int32)
Filter an ignorable whitespace event.
Declaration
public virtual void IgnorableWhitespace(char[] ch, int start, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char[] | ch | An array of characters. |
| System.Int32 | start | The starting position in the array. |
| System.Int32 | length | The number of characters to use from the array. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
NotationDecl(String, String, String)
Filter a notation declaration event.
Declaration
public virtual void NotationDecl(string name, string publicId, string systemId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The notation name. |
| System.String | publicId | The notation's public identifier, or null. |
| System.String | systemId | The notation's system identifier, or null. |
See Also
| Improve this Doc View SourceParse(InputSource)
Parse an XML document.
The application can use this method to instruct the XML reader to begin parsing an XML document from any valid input source (a character stream, a byte stream, or a URI).
Applications may not invoke this method while a parse is in progress (they should create a new XMLReader instead for each nested XML document). Once a parse is complete, an application may reuse the same XMLReader object, possibly with a different input source. Configuration of the XMLReader object (such as handler bindings and values established for feature flags and properties) is unchanged by completion of a parse, unless the definition of that aspect of the configuration explicitly specifies other behavior. (For example, feature flags or properties exposing characteristics of the document being parsed.)
During the parse, the XMLReader will provide information about the XML document through the registered event handlers.
This method is synchronous: it will not return until parsing has ended. If a client application wants to terminate parsing early, it should throw an exception.
Declaration
public virtual void Parse(InputSource input)
Parameters
| Type | Name | Description |
|---|---|---|
| InputSource | input | The input source for the top-level of the XML document. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | Any SAX exception, possibly wrapping another exception. |
| System.IO.IOException | An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
See Also
| Improve this Doc View SourceParse(String)
Parse a document.
Declaration
public virtual void Parse(string systemId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | systemId | The system identifier as a fully-qualified URI. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | Any SAX exception, possibly wrapping another exception. |
| System.IO.IOException | An IO exception from the parser, possibly from a byte stream or character stream supplied by the application. |
ProcessingInstruction(String, String)
Filter a processing instruction event.
Declaration
public virtual void ProcessingInstruction(string target, string data)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | target | The processing instruction target. |
| System.String | data | The text following the target. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
ResolveEntity(String, String)
Filter an external entity resolution.
Declaration
public virtual InputSource ResolveEntity(string publicId, string systemId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | publicId | The entity's public identifier, or null. |
| System.String | systemId | The entity's system identifier. |
Returns
| Type | Description |
|---|---|
| InputSource | A new InputSource or null for the default. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
| System.IO.IOException | The client may throw an I/O-related exception while obtaining the new InputSource. |
SetDocumentLocator(ILocator)
Filter a new document locator event.
Declaration
public virtual void SetDocumentLocator(ILocator locator)
Parameters
| Type | Name | Description |
|---|---|---|
| ILocator | locator | The document locator. |
SetFeature(String, Boolean)
Set the value of a feature.
This will always fail if the parent is null.
Declaration
public virtual void SetFeature(string name, bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The feature name. |
| System.Boolean | value | The requested feature value. |
Exceptions
| Type | Condition |
|---|---|
| SAXNotRecognizedException | If the feature value can't be assigned or retrieved from the parent. |
| SAXNotSupportedException | When the parent recognizes the feature name but cannot set the requested value. |
SetProperty(String, Object)
Set the value of a property.
This will always fail if the parent is null.
Declaration
public virtual void SetProperty(string name, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The property name. |
| System.Object | value | The requested property value. |
Exceptions
| Type | Condition |
|---|---|
| SAXNotRecognizedException | If the property value can't be assigned or retrieved from the parent. |
| SAXNotSupportedException | When the parent recognizes the property name but cannot set the requested value. |
SkippedEntity(String)
Filter a skipped entity event.
Declaration
public virtual void SkippedEntity(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of the skipped entity. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
StartDocument()
Filter a start document event.
Declaration
public virtual void StartDocument()
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
StartElement(String, String, String, IAttributes)
Filter a start element event.
Declaration
public virtual void StartElement(string uri, string localName, string qName, IAttributes atts)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | uri | The element's Namespace URI, or the empty string. |
| System.String | localName | The element's local name, or the empty string. |
| System.String | qName | The element's qualified (prefixed) name, or the empty string. |
| IAttributes | atts | The element's attributes. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
StartPrefixMapping(String, String)
Filter a start Namespace prefix mapping event.
Declaration
public virtual void StartPrefixMapping(string prefix, string uri)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | The Namespace prefix. |
| System.String | uri | The Namespace URI. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
UnparsedEntityDecl(String, String, String, String)
Filter an unparsed entity declaration event.
Declaration
public virtual void UnparsedEntityDecl(string name, string publicId, string systemId, string notationName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The entity name. |
| System.String | publicId | The entity's public identifier, or null. |
| System.String | systemId | The entity's system identifier, or null. |
| System.String | notationName | The name of the associated notation. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |
Warning(SAXParseException)
Filter a warning event.
Declaration
public virtual void Warning(SAXParseException e)
Parameters
| Type | Name | Description |
|---|---|---|
| SAXParseException | e | The warning as an exception. |
Exceptions
| Type | Condition |
|---|---|
| SAXException | The client may throw an exception during processing. |