Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

xml.parser.interface

Class XM_PARSER


Direct ancestors

XM_STRING_MODE, XM_ERROR_CODES, XM_CALLBACKS_SOURCE, XM_DTD_CALLBACKS_SOURCE, KL_IMPORTED_STRING_ROUTINES

Known direct descendants

XM_NON_INCREMENTAL_PARSER

Features

Invariants

indexing

description

Abstract definition of an XML parser

library

Gobo Eiffel XML Library

copyright

Copyright (c) 2001, Andreas Leitner and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/03/12 11:26:06 $

revision

$Revision: 1.17 $

deferred class

XM_PARSER

inherit

XM_STRING_MODE
XM_ERROR_CODES
XM_CALLBACKS_SOURCE
XM_DTD_CALLBACKS_SOURCE

feature -- Access

position: XM_POSITION

-- Current position in the XML entity being parsed.

ensure
position_not_void: Result /= Void
positions: DS_LIST [XM_POSITION]

-- Current position from the XML entity being parsed, and
-- the position where it was included.

ensure
positions_not_void: Result /= Void
source: XM_SOURCE

-- Source of the XML document being parsed.

ensure
source_not_void: Result /= Void

feature -- Status report

is_incremental: BOOLEAN

-- Can parser handle incremental input? If yes, you can feed
-- the parser with a document in several steps. You must use
-- the special parsing routines (the ones that contain
-- "incremental" in their name) to do this and call
-- finish_incremental after the last part has been fed.

is_string_mode_ascii: BOOLEAN

-- Is string mode set to ascii only?
-- This means that all strings issued by this source
-- will be of dynamic type STRING.

-- (From XM_STRING_MODE)

is_string_mode_latin1: BOOLEAN

-- Is string mode set to latin-1 only?
-- This means that all strings issued by this source
-- will be of dynamic type STRING.

-- (From XM_STRING_MODE)

is_string_mode_mixed: BOOLEAN

-- Is string mode set to polymorphic strings?
-- This means that strings issued by this source will
-- be of dynamic type STRING for ascii, and dynamic
-- type UC_STRING or descendant when characters >127
-- are present in that string.

-- (From XM_STRING_MODE)

is_string_mode_unicode: BOOLEAN

-- Is string mode set to UC_STRING only?
-- This means that all strings issued by this source
-- will be of a dynamic type UC_STRING or descendant.

-- (From XM_STRING_MODE)

same_string_mode (other: XM_STRING_MODE): BOOLEAN

-- Is other with the same string mode?

-- (From XM_STRING_MODE)

require
other_not_void: other /= Void

feature -- Status setting

set_string_mode_ascii

-- Set all strings issued by this source to be ascii
-- (all characters <= 127) and be of dynamic type STRING.
-- The source will be in an error state if it has
-- characters that do not fit in a STRING.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_ascii
set_string_mode_latin1

-- Set all strings issued by this source to be latin-1
-- (all characters <= 255) and be of dynamic type STRING.
-- The source will be in an error state if it has
-- characters that do not fit in a STRING.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_latin1
set_string_mode_mixed

-- Set all strings issued by this source to be either of
-- type UC_STRING or descendant if they contain characters
-- >127 or of dynamic type STRING otherwise.
-- The client receiving these strings will have to
-- be careful about polymorphically unsafe features
-- of STRING, like append_string.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_mixed
set_string_mode_unicode

-- Set all strings issued by this source to be of
-- dynamic type UC_STRING or descendant.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_unicode

feature -- Parsing

parse_from_public (a_public: STRING; a_system: STRING)

-- Parse from public/system identifier using resolver.

require
a_public_not_void: a_public /= Void
; a_system_not_void: a_system /= Void
parse_from_stream (a_stream: KI_CHARACTER_INPUT_STREAM)

-- Parse XML document from input stream.

require
a_stream_not_void: a_stream /= Void
is_open_read: a_stream.is_open_read
parse_from_string (a_string: STRING)

-- Parse XML document from a_string.

require
a_string_not_void: a_string /= Void
parse_from_system (a_system: STRING)

-- Parse from system identifier using resolver.

require
a_system_not_void: a_system /= Void

feature -- Incremental parsing

finish_incremental

-- Call this routine after parse_incremental_xxxx to tell
-- the parser that the document has been completely parsed
-- and no input is coming anymore.

require
is_incremental: is_incremental
parse_incremental_from_stream (a_stream: KI_CHARACTER_INPUT_STREAM)

-- Parse partial XML document from input stream.
-- After the last part of the data has been fed into the parser,
-- call finish_incremental to get any pending error messages.

require
is_incremental: is_incremental
a_stream_not_void: a_stream /= Void
is_open_read: a_stream.is_open_read
parse_incremental_from_string (a_data: STRING)

-- Parse partial XML document from 'a_data'.
-- Note: You can call parse_incremental_from_string multiple
-- times and give the parse the document in parts only.
-- You have to call finish_incremental after the last call to
-- 'parse_incremental_from_string' in every case.

require
is_incremental: is_incremental
a_data_not_void: a_data /= Void
set_end_of_document

-- Old name for finish_incremental.

obsolete

Use finish_incremental instead.

feature -- Resolving external entity

dtd_resolver: XM_EXTERNAL_RESOLVER

-- Resolver for external DTD.

entity_resolver: XM_EXTERNAL_RESOLVER

-- Resolver for external entities.

set_dtd_resolver (a_resolver: like dtd_resolver)

-- Set resolver for external DTD.

require
not_void: a_resolver /= Void
ensure
dtd_resolver_set: dtd_resolver = a_resolver
set_entity_resolver (a_resolver: like entity_resolver)

-- Set resolver for external entities.

require
not_void: a_resolver /= Void
ensure
entity_resolver_set: entity_resolver = a_resolver
set_resolver (a_resolver: like dtd_resolver)

-- Set both entity and DTD resolvers to the same one.

require
not_void: a_resolver /= Void
ensure
entity_resolver_set: entity_resolver = a_resolver
dtd_resolver_set: dtd_resolver = a_resolver

feature {XM_PARSER_STOP_ON_ERROR_FILTER} -- Error reporting

force_unreported_error (an_error: STRING)

-- Force error but do not report it to event listeners.

require
an_error_not_void: an_error /= Void
is_correct: BOOLEAN

-- Has no error been detected?

last_error: INTEGER

-- Code of last error
-- (See XM_ERROR_CODES.)

last_error_description: STRING

-- Textual description of last error

require
has_error: not is_correct
last_error_extended_description: STRING

-- Verbose textual description of last error

require
has_error: not is_correct
ensure
description_not_void: Result /= Void
new_stop_on_error_filter: XM_PARSER_STOP_ON_ERROR_FILTER

-- Create a stop on error filter that not only
-- stops forwarding events but also stops the
-- parser if the error comes from the preceding
-- event filters.
-- The result must be used only for processing events
-- coming from the current parser.

ensure
result_not_void: Result /= Void
new_stop_on_error_filter_next (a_next: XM_CALLBACKS): XM_PARSER_STOP_ON_ERROR_FILTER

-- Like 'new_stop_on_error_filter' with next
-- filter.

require
a_next_not_void: a_next /= Void
ensure
result_not_void: Result /= Void

feature

set_callbacks (a_callback: XM_CALLBACKS)

-- Client will receive callbacks to.

-- (From XM_CALLBACKS_SOURCE)

require
a_callback_not_void: a_callback /= Void
set_dtd_callbacks (a_callback: XM_DTD_CALLBACKS)

-- Client will receive callbacks to.

-- (From XM_DTD_CALLBACKS_SOURCE)

require
a_callback_not_void: a_callback /= Void

feature -- Copy

copy_string_mode (other: XM_STRING_MODE)

-- Copy string mode.

-- (From XM_STRING_MODE)

require
other_not_void: other /= Void
ensure
copied: same_string_mode (other)

feature -- Constants

xml_err_none: INTEGER

-- No error occurred

-- (From XM_ERROR_CODES)

xml_err_unknown: INTEGER

-- An unknown error occurred

-- (From XM_ERROR_CODES)

feature {XM_STRING_MODE} -- Implementation

string_mode: INTEGER

-- STRING/UC_STRING mode

-- (From XM_STRING_MODE)

invariant

entity_resolver_not_void: entity_resolver /= Void
dtd_resolver_not_void: dtd_resolver /= Void

mode_set: BOOLEAN_.nxor (<<is_string_mode_ascii, is_string_mode_mixed, is_string_mode_unicode, is_string_mode_latin1>>)

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end