sax :: XMLFilterImpl
This class is designed to sit between an XMLReader
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.
Note: The original source code and documentation of this class comes, in part, from SAX 2.0.
sax :: XMLFilterImpl :: defaultinit
sax :: XMLFilterImpl :: with_parent
Construct an XML filter with the specified parent.sax $ XMLFilterImpl :: SELF
Type of this instance, automatically specialized in every classsax $ XMLFilterImpl :: characters
Receive notification of character data.sax $ XMLFilterImpl :: content_handler
Return the current content handler.sax $ XMLFilterImpl :: content_handler=
Allow an application to register a content event handler.sax $ XMLFilterImpl :: document_locator=
Receive an object for locating the origin of SAX document events.sax $ XMLFilterImpl :: dtd_handler
Return the current DTD handler.sax $ XMLFilterImpl :: dtd_handler=
Allow an application to register a DTD event handler.sax $ XMLFilterImpl :: end_document
Receive notification of the end of a document.sax $ XMLFilterImpl :: end_element
Receive notification of the end of an element.sax $ XMLFilterImpl :: end_prefix_mapping
End the scope of a prefix-URI mapping.sax $ XMLFilterImpl :: entity_resolver
Return the current entity resolver.sax $ XMLFilterImpl :: entity_resolver=
Allow an application to register an entity resolver.sax $ XMLFilterImpl :: error
Receive notification of a recoverable error.sax $ XMLFilterImpl :: error_handler
Return the current error handler.sax $ XMLFilterImpl :: error_handler=
Allow an application to register an error event handler.sax $ XMLFilterImpl :: fatal_error
Receive notification of a non-recoverable error.sax $ XMLFilterImpl :: feature_readable
Is the retrieval of the specified feature flag supported given the current context?sax $ XMLFilterImpl :: feature_recognized
Is the specified feature flag recognized by this parser?sax $ XMLFilterImpl :: feature_writable
Is the modification of the specified feature flag supported given the current context?sax $ XMLFilterImpl :: ignorable_whitespace
Receive notification of ignorable whitespace in element content.sax $ XMLFilterImpl :: notation_decl
Receive notification of a notation declaration event.sax $ XMLFilterImpl :: parse_file
Parse an XML document from a system identifier (URI).sax $ XMLFilterImpl :: processing_instruction
Receive notification of a processing instruction.sax $ XMLFilterImpl :: property_readable
Is the retrieval of the specified property supported given the current context?sax $ XMLFilterImpl :: property_recognized
Is the specified property recognized by this parser?sax $ XMLFilterImpl :: property_writable
Is the modification of the specified property supported given the current context?sax $ XMLFilterImpl :: resolve_entity
Allow the application to resolve external entities.sax $ XMLFilterImpl :: skipped_entity
Receive notification of a skipped entity.sax $ XMLFilterImpl :: start_document
Receive notification of the beginning of a document.sax $ XMLFilterImpl :: start_element
Receive notification of the beginning of an element.sax $ XMLFilterImpl :: start_prefix_mapping
Begin the scope of a prefix-URI Namespace mapping.sax $ XMLFilterImpl :: unparsed_entity_decl
Receive notification of an unparsed entity declaration event.sax $ XMLFilterImpl :: warning
Receive notification of a warning.sax :: ContentHandler :: characters
Receive notification of character data.core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
sax :: XMLReader :: content_handler
Return the current content handler.sax :: XMLReader :: content_handler=
Allow an application to register a content event handler.sax :: XMLFilterImpl :: defaultinit
sax :: ErrorHandler :: defaultinit
sax :: XMLReader :: defaultinit
sax :: ContentHandler :: defaultinit
sax :: DTDHandler :: defaultinit
sax :: EntityResolver :: defaultinit
sax :: XMLFilter :: defaultinit
core :: Object :: defaultinit
sax :: ContentHandler :: document_locator=
Receive an object for locating the origin of SAX document events.sax :: XMLReader :: dtd_handler
Return the current DTD handler.sax :: XMLReader :: dtd_handler=
Allow an application to register a DTD event handler.sax :: ContentHandler :: end_document
Receive notification of the end of a document.sax :: ContentHandler :: end_element
Receive notification of the end of an element.sax :: ContentHandler :: end_prefix_mapping
End the scope of a prefix-URI mapping.sax :: XMLReader :: entity_resolver
Return the current entity resolver.sax :: XMLReader :: entity_resolver=
Allow an application to register an entity resolver.sax :: ErrorHandler :: error
Receive notification of a recoverable error.sax :: XMLReader :: error_handler
Return the current error handler.sax :: XMLReader :: error_handler=
Allow an application to register an error event handler.sax :: ErrorHandler :: fatal_error
Receive notification of a non-recoverable error.sax :: XMLReader :: feature_readable
Is the retrieval of the specified feature flag supported given the current context?sax :: XMLReader :: feature_recognized
Is the specified feature flag recognized by this parser?sax :: XMLReader :: feature_writable
Is the modification of the specified feature flag supported given the current context?sax :: ContentHandler :: ignorable_whitespace
Receive notification of ignorable whitespace in element content.core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
sax :: DTDHandler :: notation_decl
Receive notification of a notation declaration event.core :: Object :: output_class_name
Display class name on stdout (debug only).sax :: XMLReader :: parse_file
Parse an XML document from a system identifier (URI).sax :: ContentHandler :: processing_instruction
Receive notification of a processing instruction.sax :: XMLReader :: property_readable
Is the retrieval of the specified property supported given the current context?sax :: XMLReader :: property_recognized
Is the specified property recognized by this parser?sax :: XMLReader :: property_writable
Is the modification of the specified property supported given the current context?sax :: EntityResolver :: resolve_entity
Allow the application to resolve external entities.sax :: ContentHandler :: skipped_entity
Receive notification of a skipped entity.sax :: ContentHandler :: start_document
Receive notification of the beginning of a document.sax :: ContentHandler :: start_element
Receive notification of the beginning of an element.sax :: ContentHandler :: start_prefix_mapping
Begin the scope of a prefix-URI Namespace mapping.sax :: DTDHandler :: unparsed_entity_decl
Receive notification of an unparsed entity declaration event.sax :: ErrorHandler :: warning
Receive notification of a warning.sax :: XMLFilterImpl :: with_parent
Construct an XML filter with the specified parent.
# Base class for deriving an XML filter.
#
# This class is designed to sit between an `XMLReader`
# 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.
#
# Note: The original source code and documentation of this class comes, in part,
# from [SAX 2.0](http://www.saxproject.org).
class XMLFilterImpl
super XMLFilter
super EntityResolver
super DTDHandler
super ContentHandler
super ErrorHandler
# XMLFilter
redef var parent = null is writable
# XMLReader
redef var entity_resolver = null is writable
redef var dtd_handler = null is writable
redef var content_handler = null is writable
redef var error_handler = null is writable
############################################################################
# XMLReader
# 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
# `feature=` or `property=`, unless you use this as
# a pure event consumer rather than as an `XMLReader`.
#
# SEE: `parent`
init do
end
# Construct an XML filter with the specified parent.
#
# SEE: `parent`
init with_parent(parent_reader: XMLReader) do
parent = parent_reader
end
redef fun feature_recognized(name) do
if parent == null then
return false
else
return parent.feature_recognized(name)
end
end
redef fun feature_readable(name) do
if parent == null then
return false
else
return parent.feature_readable(name)
end
end
redef fun feature_writable(name) do
if parent == null then
return false
else
return parent.feature_writable(name)
end
end
# Look up the value of a feature.
#
# This will always fail if the parent is `null`.
#
# Parameters:
#
# * `name`: The feature name.
#
# Returns:
#
# The current value of the feature.
#
# SEE: `feature_recognized`
#
# SEE: `feature_readable`
redef fun feature(name) do
assert sax_recognized: parent != null else
sys.stderr.write("Feature: {name}\n")
end
return parent.feature(name)
end
# Set the value of a feature.
#
# This will always fail if the parent is `null`.
#
# Parameters:
#
# * `name`: feature name.
# * `value`: requested feature value.
#
# Returns:
#
# `true` if the feature is set; `false` if the feature can not be set given
# the current context.
#
# SEE: `feature_recognized`
#
# SEE: `feature_writable`
redef fun feature=(name, value) do
assert sax_recognized: parent != null else
sys.stderr.write("Feature: {name}\n")
end
parent.feature(name) = value
end
redef fun property_recognized(name) do
if parent == null then
return false
else
return parent.property_recognized(name)
end
end
redef fun property_readable(name) do
if parent == null then
return false
else
return parent.property_readable(name)
end
end
redef fun property_writable(name) do
if parent == null then
return false
else
return parent.property_writable(name)
end
end
# Look up the value of a property.
#
# Parameters:
#
# * `name`: The property name.
#
# Returns:
#
# The current value of the property.
#
# SEE: `property_recognized`
#
# SEE: `property_readable`
redef fun property(name) do
assert sax_recognized: parent != null else
sys.stderr.write("Property: {name}\n")
end
return parent.property(name)
end
# Set the value of a property.
#
# This will always fail if the parent is `null`.
#
# Parameters:
#
# * `name`: property name.
# * `value`: requested feature value.
#
# Returns:
#
# `true` if the property is set; `false` if the property can not be set
# given the current context.
#
# SEE: `property_recognized`
#
# SEE: `property_writable`
redef fun property=(name, value) do
assert sax_recognized: parent != null else
sys.stderr.write("Property: {name}\n")
end
parent.property(name) = value
end
redef fun parse(input) do
setup_parse
parent.parse(input)
end
redef fun parse_file(system_id) do
var source = new InputSource
source.system_id = system_id
parse(source)
end
############################################################################
# EntityResolver
redef fun resolve_entity(public_id, system_id) do
if entity_resolver == null then
return null
else
return entity_resolver.resolve_entity(public_id, system_id)
end
end
############################################################################
# DTDHandler
redef fun notation_decl(name, public_id, system_id) do
if dtd_handler != null then
dtd_handler.notation_decl(name, public_id, system_id)
end
end
redef fun unparsed_entity_decl(name, public_id, system_id) do
if dtd_handler != null then
dtd_handler.unparsed_entity_decl(name, public_id, system_id)
end
end
############################################################################
# ContentHandler
redef fun document_locator=(locator) do
if content_handler != null then
content_handler.document_locator = locator
end
end
redef fun start_document do
if content_handler != null then
content_handler.start_document
end
end
redef fun end_document do
if content_handler != null then
content_handler.end_document
end
end
redef fun start_prefix_mapping(prefix, uri) do
if content_handler != null then
content_handler.start_prefix_mapping(prefix, uri)
end
end
redef fun end_prefix_mapping(prefix) do
if content_handler != null then
content_handler.end_prefix_mapping(prefix)
end
end
redef fun start_element(uri, local_name, qname, atts) do
if content_handler != null then
content_handler.start_element(uri, local_name, qname, atts)
end
end
redef fun end_element(uri, local_name, qname) do
if content_handler != null then
content_handler.end_element(uri, local_name, qname)
end
end
redef fun characters(str) do
if content_handler != null then
content_handler.characters(str)
end
end
redef fun ignorable_whitespace(str) do
if content_handler != null then
content_handler.ignorable_whitespace(str)
end
end
redef fun processing_instruction(target, data) do
if content_handler != null then
content_handler.processing_instruction(target, data)
end
end
redef fun skipped_entity(name) do
if content_handler != null then
content_handler.skipped_entity(name)
end
end
############################################################################
# ErrorHandler
redef fun warning(exception) do
if error_handler != null then
error_handler.warning(exception)
end
end
redef fun error(exception) do
if error_handler != null then
error_handler.error(exception)
end
end
redef fun fatal_error(exception) do
if error_handler != null then
error_handler.fatal_error(exception)
else
exception.throw
end
end
############################################################################
# private
# Set up before a parse.
#
# Before every parse, check whether the parent is
# non-null, and re-register the filter for all of the
# events.
private fun setup_parse do
assert parent_is_not_null: parent != 0 else
sys.stderr.write("No parent for filter.")
end
parent.entity_resolver = self
parent.dtd_handler = self
parent.content_handler = self
parent.error_handler = self
end
end
lib/sax/helpers/xml_filter_impl.nit:25,1--365,3