Simple approaches to XML implementation

Ingo Macherius Ingo.Macherius at tu-clausthal.de
Sat Mar 1 02:16:59 GMT 1997


> Most documents will then need some sort of processing.  There are two
> main strategies:
> 	- event stream mode.
> 	- parse tree

I have made up a perl5 module which models a very simple forest-like strukture,
that holds Perl5 objects. The objects are created by reading nsgmls' ESIS
and putting anything between certain named tags into a hash, which
basically is the object content. The objects can be inserted as a root or into
another object, which yields a forest-like structure.
The tree-relations between objects are stored outside in a libdbm database,
one per tree. It holds three tables,	
- id -> hashed data
- id -> id of father object, or NULL
- id -> ids of all sons
Obviously any object must have a method giving a unique id within the forest.
I think this may be called a poor-mans-grove :) I made up a simple API:


	INSERT INTO DB ( when opened MODE 'write' )

        $db->insert_as_root ( $root );
        $db->insert         ( $child, 'root.id' );
        $db->update         ( $the_resource );


       QUERY THE DB
	       BASIC FUNCTIONS


        $resource =  $db->fetch  ( 'root.id' );
        $father   =  $db->father ( 'child.id' );
        @sons     =  $db->sons   ( 'root.id' );
        @roots    =  $db->roots;


	       DERIVED FUNCTIONS (recursing all nodes below given @ids)
        @sons     =  $db->all_container_sons ( @ids );
        @sons     =  $db->all_leaf_sons ( @ids );
        @sons     =  $db->all_sons ( @ids );
        @fathers  =  $db->all_fathers ( @ids );


       DESTROY DB CONTENT ( when opened MODE 'write' )
        $db->reset;

I found this sufficient to solve small problems for which ESIS is not enough
and a grove is overkill. I must admit, albeit I read most of ISO 10179, I
really didn`t get the details. But what I found valuable is the choice 
between navigating (father/son) and id-based lookups (fetch).

	++im
-- 
Snail : Ingo Macherius // L'Aigler Platz 4 // D-38678 Clausthal-Zellerfeld
Mail  : Ingo.Macherius at tu-clausthal.de WWW: http://www.tu-clausthal.de/~inim/
Information!=Knowledge!=Wisdom!=Truth!=Beauty!=Love!=Music==BEST (Frank Zappa)

xml-dev: A list for W3C XML Developers
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To unsubscribe, send to majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
List coordinator, Henry Rzepa (rzepa at ic.ac.uk)




More information about the Xml-dev mailing list