# The following was supposedly scribed by
# David Nicol
# on Friday 11 February 2005 09:14 pm:

>> The important thing to me was being able to compactly express the
>> tree structure, order, and properties in an input file.
>
>aside from the "compact" aspect, how does this differ from an XML
> document?

XML is just a generic container.  Unless I've misread your question, 
you're asking something like "how is an n-ary tree different from an 
HTML document?"

I suppose you could describe this data structure in an xml document.  
After all, xml was designed to be able to describe data.  However, 
"succinctness is power" was one of the primary goals in my design of 
the file format.  That said, feel free to write an example and 
implement a parser/loader.

The key concept here is the nature of this particular data structure.  
Perl's native data-structures only include ordered arrays and unordered 
associative arrays.  This module uses tied associative arrays and some 
conventions to represent ordered trees where each node of the tree has 
both contents (deeper nodes) and properties (things about the node.)  
It's not exactly homogeneous (like an n-ary tree) because it uses a 
file/directory concept (a "directory" contains more nodes (a recursive 
version of the same data-structure), but a "file" only contains flat 
data (as arrays.))

The module code that I've written so far doesn't allow you to build the 
data structure in-memory, but the goal was to have something that is 
useful for describing/manipulating filesystem-like data structures 
in-memory.  I may end up scrapping or changing this file format as the 
idea takes a better shape, but this was the best that I could come up 
with to load an ordered associative array without handling all of the 
edge-cases that come with writing a complete parser from scratch.  
Ultimately, the ordered hash isn't essential to the concept of this 
data-structure (though it is required for my current application of it 
- driving an HTML::Mason site's navbars, etc. via a single sitemap 
file.)

--Eric
-- 
"Everything should be made as simple as possible, but no simpler."
                                        --Albert Einstein

Reply via email to