Results 1 to 10 of 10
Jun 6, 2007, 11:58 #1
- Join Date
- Jun 2007
- Hoorn, The Netherlands
- 0 Post(s)
- 0 Thread(s)
Wrapping DOM in objects - what kind of approach?
I am struggling to come up with a clear, readable, usable and OO-friendly approach to parse and manipulate a custom xml format using objects which represent the xml elements. To illustrate here is a basic xml file using this format:
<?xml version='1.0' encoding='UTF-8'?> <form id='form001' code='form001' version='1' description='form001_desc'> <dimensions> <dimension id='dim_01'> <levels> <level id='dim_01_l01' depth='1'> <members> <member id='dim_01_l02_m01 </members> </level> </levels> </dimension> </dimensions> <cubes> <cube id='c01'> <axiss> <axis id='rows'> <dimensionlist> <dimensionref dimensionid='dim_01'/> </dimensionlist> <tupels> <tupel id='r_1'> <memberref memberid='dim_01_l02_m01'/> </tupel> </tupels> </axis> </axiss> </cube> </cubes> </form>
The complete xml format has many more elements (not every container element has only one type of child element) but I choose not to show them here as they would only waste space. The overal concept is the same as showed above.
The approach I've narrowed in on is that of a builder class, say FormEditor, which works with Object representations of the 'real' elements.
In this example those objects would be
the Form object would have the following attributes and methods
The other Objects would all use this kind of approach. The function of the getXML() method creates a DOMElement object with the tagname of the element the object is representing, that would be <form> in this example.
Then it would set all the attributes, after this it would loop over the aDimensions and aCubes array and then call the getXML() method on these objects.
getXML finally returns the DOMElement object.
My problem now is: (yes finally ) How would I retrieve a specific Member Object from the top-level Form Element because the Member object is waaaay down in the object hierarchy:
Form Dimension Level Member
P.S. I apologize if some of my concepts are badly explained. English not my mother tongue.
Last edited by linde002; Jun 6, 2007 at 12:00. Reason: Uncompleted sentence