[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is DOM vs SAX a red herring?





Phil Shafer wrote:
Larry Menten writes:
  
But the use of elements does require that the parsed elements be cached until enough
information has been collected to parse them.  Except for trivial examples, this means that
you will be allocating memory dynamically to store these until you have collected enough
elements to identify and configure the target object.
...
You have provided just the leaf.  With JUNOS  you must retain the entire 
tree in memory:
...
I am storing just the name, namespace ID, and attribute list for one 
single element.
    

Given that the data is hierarchical in nature, how does using
attributes relieve you from tracking where you are in the configuration
hierarchy? You've got to know the parent hierarchy for your particular
element, so you need to track the same information. Attributes may
change the form of the data, but not what you need to do with it.
SAX may give you a complete set of attributes at once, but it will
normally allocate memory for these strings before handing them to
your code. I'm not following the element-implies-dom-implies-big
progression, mostly 'cause we use element, don't use DOM, and have
a fairly small footprint.

Thanks,
 Phil
  
If you are familiar with GOF terminaology, we use a facade class tree that represents the
hierarchy.  It is statically allocated.  The tree guides the parsing and retains the context
as the document is processed.  The context is retained in binary representation.
Very compact, but providing access to the configuration state of the ancestors
of the current element.  No dynamic memory allocation.

How much code is required to implement the manangement of the interface object
within an OSPF area?  I add a few tens of lines of code to a generic template C++ file.

How many lines of code do you create?  How much dynamic memory allocation do you perform?

Larry
-- 
Larry Menten               Lucent Technologies/Bell Laboratories
Phone: 908 582-4467        600 Mountain Avenue, Murray Hill, NJ  07974 USA