• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

parsing a graph

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is is possible to use DOM or SAX to parse a graph instead of a tree? (an element in a graph can have more than 1 parent). Thank you.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not clear on how you would represent a graph in XML
with more than one parent. I can certainly visualize a
graph that has the properties you mention, but not in an XML form...

Am I missing something here or does any given XML element, well
formed XML if I may add, (except the root) have one and only one
(immediate) parent.

What's the catch Thomas?

- m
[ November 05, 2004: Message edited by: Madhav Lakkapragada ]
 
thomas wilson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Madhav,

Thank you for answering. Here is the situation. There are n layers (less than 10) in a 'tree' and each layer corresponds to a table in an Oracle database. When a user traverses the tree by clicking on nodes on a GUI, he/she should be able to go backtrack if needed. Assume that the user cannot backtrack more than n times, I can always use n session variables (perhaps in an array) to store the position (with timestamp to keep the chronological order of traversing). My other thought is to map the database tables to an internal XML tree and use DOM to store the traverse path. The twist of the latter solution is because each entry in the tables (except the root table) can have more than 1 parent (from the preceding upper layer/table), one might have to duplicate those entries as new elements in the XML tree. I assume that there are better ways to keep track of the path. If you or anyone know, please educate me. Thanks again. The apps is in J2EE.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry but I am completely lost.

- m
 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Madhav mentioned in his earlier post, an XML file is really a tree structure. So, if you want to store your graph in an XML you have to either

a) convert the graph into a tree structure(hence duplicating the nodes)
OR
b) store the path as a seperate structure. So, your XML will look like this

<Node tablename="Table1" ..../>
<Node tablename="Table2" ..../>
.
.
repeat for n paths
.
<Node tablename="TableN"/>
<Path name="path1">
<Table name="Table1"/>
<Table name="Table3"/>
</Path>
.
.
.
repeat for all the possible paths
.
.
.

BTW, why do you want to store your graph structure as an XML?
 
thomas wilson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Madhav and Jayesh. I store the graph as a tree as one of the ways to backtrack the path. Like I mentioned, another way might be simply to store the positions with session variables (ID, timestamp)
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like there's a bit of a disconnect - for me - as to what you mean by store.

From what you described, I think you mean store in a database.

The disconnect that I have is how you are attempting to represent this
table data in an XML form?
That's what I am trying to understand.

- m
[ November 10, 2004: Message edited by: Madhav Lakkapragada ]
 
thomas wilson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Madhav,

You can do this by using DOM which can not only parse an xml document but also create one from data retrieved from the database.

http://www.ibiblio.org/xml/books/xmljava/chapters/ch13s03.html
[ November 11, 2004: Message edited by: thomas wilson ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic