[XML-SIG] Choosing an XML method for a backing store

Darren Hart darren at dvhart.com
Sun Sep 21 20:57:41 CEST 2008

I'm writing a simple application that has a tree-like data structure.
I'd like to be able to eventually easily synchronize this data from
one client to another.  With that in mind, I have a few questions
regarding how I should best store my data and whether DOM or SAX is a
more appropriate choice.  I am new to XML and am trying to make sure
I'm headed in the right direction before I make any pervasive changes
to my application.  If I'm barking up the wrong tree, can someone
point me in the right direction?

Example data structure

list of type A
  type A
  type A

tree of types B,C,D,E
type B
  list of type C
    type C
      type B ref
      list of type D
        type D
          type C ref
          list of type E
            type D ref
            list of type A ref
              type A ref
              type A ref

1) The structure seems to lend itself well to DOM

2) Using DOM seems to mean one single file, which makes synchonization
harder and more error prone, lots of individual files seem like a
better approach for that

3) Since I already have a data structure, it seems I'd end up building
the DOM, then constructing the data structure from the DOM, then
writing the entire thing out on each save... seems to invalidate some
of the benefits of a DOM (easy reorganization of nodes for example).

4) Is it common practice to subclass the DOM objects into something my
application can use explicitly, thus avoiding the need to convert from
the DOM to the structure outlined above?  My objects currently use
signals to communication with the GUI and other objects.

5) Is there a common practice for dealing with the references in my
data structure?  For example, when parsing the XML file(s) with SAX it
is possible I'll come across a reference to an object that hasn't yet
been created and is defined elsewhere in the file (or another file).
My thought was to store a unique ID for each object, and use object
reference elements in the xml with the unique as CTEXT, if this is
encountered and the object hasn't been constructed, a proxy object
would be built and converted to a complete object when the xml data
for it was encountered.

Thanks for the time,

Darren Hart

More information about the XML-SIG mailing list