Core SAX APIs.

This is a (partial) port of the original SAX API. See http://www.saxproject.org for more information about SAX.

SAX2 Standard Feature Flags:

One of the essential characteristics of SAX2 is that it added feature flags which can be used to examine and perhaps modify parser modes, in particular modes such as validation. Since features are identified by (absolute) URIs, anyone can define such features.

For default values not specified by SAX2, each XMLReader implementation specifies its default, or may choose not to expose the feature flag. Unless otherwise specified here, implementations may support changing current values of these standard feature flags, but not while parsing.

Currently defined standard feature URIs have the prefix http://xml.org/sax/features/ before an identifier such as validation. Support for the default values of the namespaces and namespace-prefixes properties is required. Turn features on or off using feature=. Those standard identifiers are:

external-general-entities:

  • Access: read/write
  • Default: unspecified
  • Description: Reports whether this parser processes external general entities; always true if validating.

external-parameter-entities:

  • Access: read/write
  • Default: unspecified
  • Description: Reports whether this parser processes external parameter entities; always true if validating.

is-standalone:

  • Access: read-only while parsing, none while not parsing
  • Default: not applicable
  • Description: May be examined only during a parse, after the start_document callback has been completed; read-only. The value is true if the document specified standalone="yes" in its XML declaration, and otherwise is false.

lexical-handler/parameter-entities:

  • Access: read/write
  • Default: unspecified
  • Description: true indicates that the LexicalHandler will report the beginning and end of parameter entities.

namespaces:

  • Access: read/write
  • Default: true
  • Description: true indicates namespace URIs and unprefixed local names for element and attribute names will be available.

namespace-prefixes:

  • Access: read/write
  • Default: false
  • Description: true indicates XML 1.0 names (with prefixes) and attributes (including xmlns* attributes) will be available.

resolve-dtd-uris:

  • Access: read/write
  • Default: true
  • Description: true indicates that system IDs in declarations will be absolutized (relative to their base URIs) before reporting. (That is the default behavior for all SAX2 XML parsers.) A value of "false" indicates those IDs will not be absolutized; parsers will provide the base URI from SAXLocator.system_id. This applies to system IDs passed in DTDHandler.notation_decl, DTDHandler.unparsed_entity_decl, and DeclHandler.external_entity_decl. It does not apply to EntityResolver.resolve_entity, which is not used to report declarations, or toLexicalHandler.start_dtd`, which already provides the non-absolutized URI.

string-interning:

  • Access: read-only
  • Default: false
  • Description: (Java-specific. Not supported in Nit.)

unicode-normalization-checking:

  • Access: read/write
  • Default: false
  • Description: Controls whether the parser reports Unicode normalization errors as described in section 2.13 and Appendix B of the XML 1.1 Recommendation. If true, Unicode normalization errors are reported using the ErrorHandler.error callback. Such errors are not fatal in themselves (though, obviously, other Unicode-related encoding errors may be).

use-attributes2:

  • Access: read-only
  • Default: not applicable
  • Description: Returns true if the Attributes objects passed by this parser in ContentHandler.start_element implement the sax::ext::Attributes2 interface. That interface exposes additional DTD-related information, such as whether the attribute was specified in the source text rather than defaulted.

TODO: interface not yet available in Nit.

use-locator2:

  • Access: read-only
  • Default: not applicable
  • Description: Returns true if the SAXLocator objects passed by this parser in ContentHandler.document_locator= implement the sax::ext::SAXLocator2 interface. That interface exposes additional entity information, such as the character encoding and XML version used.

TODO: interface not yet available in Nit.

use-entity-resolver2:

  • Access: read/write
  • Default: true
  • Description: Returns true if, when entity_resolver is given an object implementing the sax::ext::EntityResolver2 interface, those new methods will be used. Returns false to indicate that those methods will not be used.

validation:

  • Access: read/write
  • Default: unspecified
  • Description: controls whether the parser is reporting all validity errors; if true, all external entities will be read.

xmlns-uris:

  • Access: read/write
  • Default: false
  • Description: Controls whether, when the namespace-prefixes feature is set, the parser treats namespace declaration attributes as being in the http://www.w3.org/2000/xmlns/ namespace. By default, SAX2 conforms to the original "Namespaces in XML" Recommendation, which explicitly states that such attributes are not in any namespace. Setting this optional flag to true makes the SAX2 events conform to a later backwards-incompatible revision of that recommendation, placing those attributes in a namespace.

xml-1.1:

  • Access: read-only
  • Default: not applicable
  • Description: Returns true if the parser supports both XML 1.1 and XML 1.0. Returns "false" if the parser supports only XML 1.0.

SAX2 Standard Handler and Property IDs:

For parser interface characteristics that are described as objects, a separate namespace is defined. The objects in this namespace are again identified by URI, and the standard property URIs have the prefix http://xml.org/sax/properties/ before an identifier such as lexical-handler or dom-node. All of these standard properties are optional; XMLReader implementations need not support them. Manage those properties using property=. Those identifiers are:

declaration-handler:

Used to see most DTD declarations except those treated as lexical (“document element name is...”) or which are mandatory for all SAX parsers (DTDHandler). The object must implement sax::ext::DeclHandler.

document-xml-version:

May be examined only during a parse, after the start_document callback has been completed; read-only. This property is a literal string describing the actual XML version of the document, such as "1.0" or "1.1".

dom-node:

For “DOM Walker” style parsers, which ignore their parser.parse parameters, this is used to specify the DOM (sub)tree being walked by the parser. The object must implement the xml.dom.Node interface.

TODO: interface not yet available in Nit.

lexical-handler:

Used to see some syntax events that are essential in some applications: comments, CDATA delimeters, selected general entity inclusions, and the start and end of the DTD (and declaration of document element name). The object must implement sax::ext::LexicalHandler.

xml-string:

Readable only during a parser callback, this exposes a TBS chunk of characters responsible for the current event.

Note: The original documentation comes from SAX 2.0.

All class definitions

package_diagram sax::sax sax sax::xml_filter xml_filter sax::sax->sax::xml_filter sax::xml_reader xml_reader sax::xml_filter->sax::xml_reader ...sax::xml_reader ... ...sax::xml_reader->sax::xml_reader sax::ext ext sax::ext->sax::sax sax::helpers helpers sax::helpers->sax::sax saxophonit::reader_model reader_model saxophonit::reader_model->sax::sax a_star-m a_star-m a_star-m->sax::ext a_star-m->sax::helpers a_star-m... ... a_star-m...->a_star-m saxophonit::lexer lexer saxophonit::lexer->saxophonit::reader_model saxophonit::lexer... ... saxophonit::lexer...->saxophonit::lexer

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module array

core :: array

This module introduces the standard array structure.
module attributes

sax :: attributes

Interface for a list of XML attributes.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module content_handler

sax :: content_handler

Receives notification of the logical content of a document.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module dtd_handler

sax :: dtd_handler

Receives notification of basic DTD-related events.
module entity_resolver

sax :: entity_resolver

Basic interface for resolving entities.
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module error_handler

sax :: error_handler

Basic interface for SAX error handlers.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module input_source

sax :: input_source

A single input source for an XML entity.
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module list

core :: list

This module handle double linked lists
module math

core :: math

Mathematical operations
module native

core :: native

Native structures for text and bytes
module numeric

core :: numeric

Advanced services for Numeric types
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module sax_locator

sax :: sax_locator

Interface for associating a SAX event with a document location.
module sax_parse_exception

sax :: sax_parse_exception

Encapsulates an XML parse error or warning.
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module xml_reader

sax :: xml_reader

Interface for reading an XML document using callbacks.

Parents

module xml_filter

sax :: xml_filter

Interface for an XML filter.

Children

module ext

sax :: ext

Interfaces to optional SAX2 handlers.
module helpers

sax :: helpers

Contains "helper" classes, including support for bootstrapping SAX-based applications.
module reader_model

saxophonit :: reader_model

Reader’s model.

Descendants

module a_star-m

a_star-m

module lexer

saxophonit :: lexer

SAXophoNit’s lexer
module saxophonit

saxophonit :: saxophonit

A SAX 2 parser in Nit.
# Core SAX APIs.
#
# This is a (partial) port of the original SAX API. See
# [http://www.saxproject.org](http://www.saxproject.org) for more information
# about SAX.
#
# SAX2 Standard Feature Flags:
#
# One of the essential characteristics of SAX2 is that it added
# feature flags which can be used to examine and perhaps modify
# parser modes, in particular modes such as validation.
# Since features are identified by (absolute) URIs, anyone
# can define such features.
#
# For default values not specified by SAX2,
# each `XMLReader` implementation specifies its default,
# or may choose not to expose the feature flag.
# Unless otherwise specified here,
# implementations may support changing current values
# of these standard feature flags, but not while parsing.
#
# Currently defined standard feature URIs have the prefix
# `http://xml.org/sax/features/` before an identifier such as
# `validation`. Support for the default values of the
# `namespaces` and `namespace-prefixes`
# properties is required. Turn features on or off using
# `feature=`. Those standard identifiers are:
#
# `external-general-entities`:
#
# * Access: read/write
# * Default: unspecified
# * Description: Reports whether this parser processes external general
# entities; always `true` if validating.
#
# `external-parameter-entities`:
#
# * Access: read/write
# * Default: unspecified
# * Description: Reports whether this parser processes external parameter
# entities; always `true` if validating.
#
# `is-standalone`:
#
# * Access: read-only while parsing, none while not parsing
# * Default: not applicable
# * Description: May be examined only during a parse, after the `start_document`
# callback has been completed; read-only. The value is `true` if the document
# specified `standalone="yes"` in its XML declaration, and otherwise is `false`.
#
# `lexical-handler/parameter-entities`:
#
# * Access: read/write
# * Default: unspecified
# * Description: `true` indicates that the LexicalHandler will report the
# beginning and end of parameter entities.
#
# `namespaces`:
#
# * Access: read/write
# * Default: `true`
# * Description: `true` indicates namespace URIs and unprefixed local names
# for element and attribute names will be available.
#
# `namespace-prefixes`:
#
# * Access: read/write
# * Default: `false`
# * Description: `true` indicates XML 1.0 names (with prefixes) and attributes
# (including `xmlns*` attributes) will be available.
#
# `resolve-dtd-uris`:
#
# * Access: read/write
# * Default: `true`
# * Description: `true` indicates that system IDs in declarations will be
# absolutized (relative to their base URIs) before reporting. (That is the
# default behavior for all SAX2 XML parsers.) A value of "false" indicates those
# IDs will not be absolutized; parsers will provide the base URI from
# `SAXLocator.system_id`. This applies to system IDs passed in
# `DTDHandler.notation_decl`, DTDHandler.unparsed_entity_decl`, and
# `DeclHandler.external_entity_decl`. It does not apply to
# `EntityResolver.resolve_entity`, which is not used to report declarations, or
# to `LexicalHandler.start_dtd`, which already provides the non-absolutized URI.
#
# `string-interning`:
#
# * Access: read-only
# * Default: `false`
# * Description: (Java-specific. Not supported in Nit.)
#
# `unicode-normalization-checking`:
#
# * Access: read/write
# * Default: `false`
# * Description: Controls whether the parser reports Unicode normalization
# errors as described in section 2.13 and Appendix B of the XML 1.1
# Recommendation. If `true`, Unicode normalization errors are reported using
# the `ErrorHandler.error` callback. Such errors are not fatal in themselves
# (though, obviously, other Unicode-related encoding errors may be).
#
# `use-attributes2`:
#
# * Access: read-only
# * Default: not applicable
# * Description: Returns `true` if the `Attributes` objects passed by this
# parser in `ContentHandler.start_element` implement the
# `sax::ext::Attributes2` interface. That interface exposes additional
# DTD-related information, such as whether the attribute was specified in the
# source text rather than defaulted.
#
# TODO: interface not yet available in Nit.
#
# `use-locator2`:
#
# * Access: read-only
# * Default: not applicable
# * Description: Returns `true` if the `SAXLocator` objects passed by this
# parser in `ContentHandler.document_locator=` implement the
# `sax::ext::SAXLocator2` interface. That interface exposes additional
# entity information, such as the character encoding and XML version used.
#
# TODO: interface not yet available in Nit.
#
# `use-entity-resolver2`:
#
# * Access: read/write
# * Default: true
# * Description: Returns `true` if, when `entity_resolver` is given an object
# implementing the `sax::ext::EntityResolver2` interface, those new methods
# will be used. Returns `false` to indicate that those methods will not be used.
#
# `validation`:
#
# * Access: read/write
# * Default: unspecified
# * Description: controls whether the parser is reporting all validity errors;
# if true, all external entities will be read.
#
# `xmlns-uris`:
#
# * Access: read/write
# * Default: `false`
# * Description: Controls whether, when the `namespace-prefixes` feature is set,
# the parser treats namespace declaration attributes as being in the
# `http://www.w3.org/2000/xmlns/` namespace. By default, SAX2 conforms to the
# original "Namespaces in XML" Recommendation, which explicitly states that such
# attributes are not in any namespace. Setting this optional flag to `true`
# makes the SAX2 events conform to a later backwards-incompatible revision of
# that recommendation, placing those attributes in a namespace.
#
# `xml-1.1`:
#
# * Access: read-only
# * Default: not applicable
# * Description: Returns `true` if the parser supports both XML 1.1 and XML 1.0.
# Returns "false" if the parser supports only XML 1.0.
#
#
# SAX2 Standard Handler and Property IDs:
#
# For parser interface characteristics that are described as objects, a
# separate namespace is defined. The objects in this namespace are again
# identified by URI, and the standard property URIs have the prefix
# `http://xml.org/sax/properties/` before an identifier such as
# `lexical-handler` or `dom-node`. All of these standard properties are
# optional; `XMLReader` implementations need not support them. Manage those
# properties using `property=`. Those identifiers are:
#
# `declaration-handler`:
#
# Used to see most DTD declarations except those treated as lexical (“document
# element name is...”) or which are mandatory for all SAX parsers
# (`DTDHandler`). The object must implement `sax::ext::DeclHandler`.
#
# `document-xml-version`:
#
# May be examined only during a parse, after the `start_document` callback
# has been completed; read-only. This property is a literal string describing
# the actual XML version of the document, such as `"1.0"` or `"1.1"`.
#
# `dom-node`:
#
# For “DOM Walker” style parsers, which ignore their `parser.parse` parameters,
# this is used to specify the DOM (sub)tree being walked by the parser. The
# object must implement the `xml.dom.Node` interface.
#
# TODO: interface not yet available in Nit.
#
# `lexical-handler`:
#
# Used to see some syntax events that are essential in some applications:
# comments, `CDATA` delimeters, selected general entity inclusions, and the
# start and end of the DTD (and declaration of document element name).
# The object must implement `sax::ext::LexicalHandler`.
#
# `xml-string`:
#
# Readable only during a parser callback, this exposes a **TBS** chunk of
# characters responsible for the current event.
#
# Note: The original documentation comes from [SAX 2.0](http://www.saxproject.org).
module sax

import attributes
import content_handler
import dtd_handler
import entity_resolver
import error_handler
import input_source
import sax_locator
import sax_parse_exception
import xml_filter
import xml_reader
lib/sax/sax.nit:11,1--224,17