Github

Download version 1.4.8: Windows or Linux

Persistency Library: Xpath orientated XML node scanners and Eiffel object builders

A library implementing various kinds of XML document node scanners fed by 5 different types of XML node parse event generators. These 5 types, all descendants of class EL_PARSE_EVENT_SOURCE, are as follows:

1. EL_EXPAT_XML_PARSER: An Eiffel binding to the eXpat XML parser

2. EL_EXPAT_XML_PARSER_OUTPUT_MEDIUM: eXpat XML parser of XML serializeable objects conforming to EVOLICITY_SERIALIZEABLE_AS_XML.

3. EL_EXPAT_XML_WITH_CTRL_Z_PARSER: eXpat XML parser with input stream end delimited by Ctrl-Z character. Useful for parsing network streams.

4. EL_BINARY_ENCODED_XML_PARSE_EVENT_SOURCE: a binary encoded XML event source. Useful for reducing the size of large documents.

5. EL_PYXIS_PARSER event from a Pyxis format parser. Pyxis is a direct analog of XML that is easier to read and edit making it suitable for configuration files.

The following are the various kinds of scanners which can process the output from these event sources.

Eiffel Object Building Scanners

The classes EL_BUILDABLE_FROM_XML and EL_BUILDABLE_FROM_PYXIS can be used to implement a sophisticated Eiffel object building scheme based on the idea of mapping builder agents to xpaths relative to particular element contexts. Only a small subset of the xpath standard is used. The framework has the following features:

General Xpath to Eiffel agent mapper

The class EL_CREATEABLE_FROM_XPATH_MATCH_EVENTS implements a method for scanning a document and triggering various Eiffel agents according to a table of xpath to agent mappings.

Eiffel Aware Document Scanner

The class EL_SMART_BUILDABLE_FROM_NODE_SCAN is an XML parser that reacts to a special XML processing instruction, telling it to build an Eiffel object of a particular type.

ECF: xdoc-scanning.ecf

Directory: library/persistency/xml/xdoc-scanning

[ . ]

. /event-sources/binary-encoded

. /event-sources/expat-parser

. /event-sources/expat-parser/modified-gobo

. /event-sources/pyxis

. /scanners

. /scanners/eiffel-object-building

. /scanners/eiffel-object-building/buildable

. /scanners/eiffel-object-building/smart-builder

. /scanners/node-event

. /scanners/node-event/xhtml

. /scanners/xpath-scan

. /support

. /support/unused

[ . ]

EL_CREATEABLE_FROM_NODE_SCAN

Object that is createable from XML parse events

EL_PARSE_EVENT_SOURCE

EL_XML_NODE_CLIENT

event-sources/binary-encoded

EL_BINARY_ENCODED_XML_PARSE_EVENT_SOURCE

event-sources/expat-parser

EL_EXPAT_XML_PARSER

Wrapper for eXpat XML parser.

Further Information

Click on class link to see notes.

EL_EXPAT_XML_WITH_CTRL_Z_PARSER

Parses XML from a stream until a Ctrl-z character is encounterd. Use for parsing a network stream of XML.

EL_EXPAT_XML_ATTRIBUTE_LIST

EL_EXPAT_XML_PARSER_OUTPUT_MEDIUM

event-sources/expat-parser/modified-gobo

EL_EXPAT_API

Expat API and associated classes modified to only have ISE base dependency

EL_XML_DEFAULT_POSITION

Positions in an XML document which has been parsed from a stream

EL_XML_DEFAULT_URI_SOURCE

The source of an XML document that has been retrieved via an URI

EL_XML_POSITION

Abstract definition of positions in XML documents

EL_XML_SOURCE

Abstract definition of the source of an XML document

EL_XML_STREAM_POSITION

Abstract definition of positions in XML documents which have been parsed from streams

EL_XML_STRING_SOURCE

Strings as source of XML documents

event-sources/pyxis

EL_PYXIS_RESOURCE_SET

Object for caching XML conversions of resource set in Pyxis format installed in application directory

EL_PYXIS_TREE_COMPILER

Command to compile tree of UTF-8 encoded Pyxis source files into something else Performs file date time checking to decide if compilation target is up to date.

EL_PYXIS_XML_TEXT_GENERATOR

XML generator that does not split text nodes on new line character. Tabs and new lines in from text content are escaped.

EL_MODULE_PYXIS

EL_PYTHON_UNESCAPE_CONSTANTS

EL_PYXIS_ATTRIBUTE_PARSER

EL_PYXIS_ENCODING

EL_PYXIS_PARSER

EL_PYXIS_STRING_LIST

EL_PYXIS_XML_ROUTINES

EL_PYXIS_ZTEXT_PATTERN_FACTORY

scanners

EL_XML_DOCUMENT_SCANNER

Scans sequentially the XML node visiting events originating from event_source.

The event source can be any of the following types:

1. EL_EXPAT_XML_PARSER: Expat XML parser

2. EL_EXPAT_XML_PARSER_OUTPUT_MEDIUM: Expat XML parser of XML serializeable objects conforming to EVOLICITY_SERIALIZEABLE_AS_XML.

3. EL_EXPAT_XML_WITH_CTRL_Z_PARSER: Expat XML parser with input stream end delimited by Ctrl-Z character. Useful for parsing network streams.

4. EL_BINARY_ENCODED_XML_PARSE_EVENT_SOURCE: a binary encoded XML event source.

5. EL_PYXIS_PARSER: event from a Pyxis format parser. Pyxis is a direct analog of XML that is easier to read and edit thus making it more suitable for configuration files.

EL_XML_NODE_SCAN_SOURCE

Object that applies XML parse events to the construction of an object

EL_XML_DOCUMENT_LOGGER

EL_XML_PARSE_EVENT_GENERATOR

EL_XML_TEXT_GENERATOR

scanners/eiffel-object-building

EL_EIF_OBJ_BUILDER_CONTEXT

Eiffel object model Xpath context

Further Information

Click on class link to see client examples.

EL_EIF_OBJ_TEXT_TABLE_CONTEXT

Convenience class to store all element values for a context in a table but without recursing deeper

EL_XML_NODE_SCAN_TO_EIFFEL_OBJECT_BUILDER

Eiffel object model

EL_XPATH_PARSER

Simple xpath parser that can parse xpaths like the following:

AAA/BBB
AAA/BBB/@name
AAA/BBB[@id='x']
AAA/BBB[@id='x']/@name
AAA/BBB[id='y']/CCC/text()

<AAA>
   <BBB id="x" name="foo">
   </BBB>
   <BBB id="y" name="bar">
      <CCC>hello</CCC>
   </BBB>
</AAA>

but cannot parse:

AAA/BBB[2]/@name

EL_DEFAULT_EIF_OBJ_XPATH_CONTEXT

EL_EIF_OBJ_ROOT_BUILDER_CONTEXT

EL_EIF_OBJ_XPATH_CONTEXT

EL_PARSED_XPATH_STEP

EL_XML_TO_EIFFEL_OBJECT_BUILDER_I

scanners/eiffel-object-building/buildable

EL_BUILDABLE_FROM_NODE_SCAN

Top level abstraction for building nested Eiffel objects by matching relative xpaths to an XML parse event source defined by new_node_source. The xpaths are mapped to agents by implementing the function building_action_table found in class EL_EIF_OBJ_BUILDER_CONTEXT. Typically the agents assign a class attribute value by calling a value function of the last_node object. But the agent might also change the Eiffel object context by calling the procedure set_next_context. The new context is mapped to some element in the document and all xpaths in the new current context are relative to this element. Returning to the parent context happens automatically when all the nodes in the current element have been visited. The top level context is defined by implementing the attribute root_node_name which defines the root element name.

The most useful descendants of this class are EL_BUILDABLE_FROM_XML and EL_BUILDABLE_FROM_PYXIS. The latter implements a parser for Pyxis, an XML analog with a Python inspired syntax.

EL_BUILDABLE_FROM_PYXIS

Object buildable from node parse events generated by EL_PYXIS_PARSER

EL_BUILDABLE_FROM_XML

Object buildable from node parse events generated by EL_EXPAT_XML_PARSER

EL_FILE_PERSISTENT_BUILDABLE_FROM_NODE_SCAN

EL_FILE_PERSISTENT_BUILDABLE_FROM_PYXIS

EL_FILE_PERSISTENT_BUILDABLE_FROM_XML

scanners/eiffel-object-building/smart-builder

EL_EIF_OBJ_FACTORY_ROOT_BUILDER_CONTEXT

Root builder context that changes the type of the target object to build according to a processing instruction at the start of the XML. The example below will build an instance of class SMIL_PRESENTATION.

<?xml version="1.0" encoding="utf-8"?>
<?create {SMIL_PRESENTATION}?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
..
</smil>

EL_SMART_BUILDABLE_FROM_NODE_SCAN

XML parser that reacts to a special processing instructions before the root element of the form:

<?create {MY_CLASS}?>

MY_CLASS represents an implementation of the deferred class EL_BUILDABLE_FROM_XML and it knows how to build itself from this type of document. The built object is accessible via the attribute target.

EL_SMART_XML_TO_EIFFEL_OBJECT_BUILDER

Detects the desired target type from XML processing instruction create {G} and sets the type of target_object to G where G is a type conforming to EL_BUILDABLE_FROM_XML. Built object is made available as product.

scanners/node-event

EL_XML_NODE_EVENT_GENERATOR

EL_XML_NODE_EVENT_HANDLER

scanners/node-event/xhtml

EL_XHTML_WORD_COUNTER

scanners/xpath-scan

EL_CREATEABLE_FROM_XPATH_MATCH_EVENTS

Object that scans an XML node event source, matching visited nodes against a user defined set of xpaths. Matching nodes trigger a call to an agent defined in the mapping function xpath_match_events. The agent can process the visited node by accessing the last_node attribute. Although only a tiny subset of the xpath standard is implemented, it is still quite useful as this rudimentary XHTML renderer, EL_HTML_TEXT, illustrates.

The following xpath to agent map is from the example class BIOINFO_XPATH_MATCH_EVENTS. The first mapping argument on_open or on_close applies only to element nodes and specifies whether to call the agent when the element open tag or closing tag is encountered.

xpath_match_events: ARRAY [EL_XPATH_TO_AGENT_MAP]
      --
   do
      Result := <<
         -- Fixed paths
         [on_open, "/bix/package/env/text()", agent on_package_env],
         [on_open, "/bix/package/command/action/text()", agent on_command_action],
         [on_open, "/bix/package/command/parlist/par/value/@type", agent
                                                     on_parameter_list_value_type],
         [on_open, "/bix/package/command/parlist/par/value/text()", agent
                                                          on_parameter_list_value],

         [on_close, "/bix", agent log_results], -- matches only when closing tag
                                                                        encountered

         -- Wildcard paths
         [on_open, "//par/value/*", agent on_parameter_data_value_field],
         [on_open, "//label/text()", agent on_label],
         [on_open, "//label", agent increment (label_count)],
         [on_open, "//par/id", agent increment (par_id_count)],

         [on_open, "//par/id/text()", agent on_par_id]
      >>
   end

EL_TOKENIZED_XPATH

Tokenized form of xpath

EL_XPATH_MATCH_SCAN_SOURCE

Class for parsing XML documents and matching sets of xpaths

EL_XPATH_TOKEN_CONSTANTS

EL_XPATH_TOKEN_TABLE

EL_XPATH_TO_AGENT_MAP

support

EL_SMIL_VALUE_PARSING

EL_XML_ATTRIBUTE_LIST

EL_XML_ATTRIBUTE_NODE

EL_XML_CYCLIC_REDUNDANCY_CHECK_32

EL_XML_NODE

EL_XML_PARSER_OUTPUT_MEDIUM

EL_XML_PARSE_EVENT_STREAM

support/unused

EL_LATIN1_XML_NODE

EL_UTF8_XML_NODE