This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parse large xmlfile and display using swing

 
Nisha Soorya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to read a large xml file and display graphically in swing as a tree structure.

I implemented it and works fine for files of 5MB size after increasing the jvm heap size (-Xmx). If the file size is larger than 5MB it throws out of memory error. I'm creating a custom datastructure from the xml and I'm using sax parsing.

After displaying the datastructure, the user could do some operation on this, like search etc.

Can any of you suggest a method, to support larger files ? What I'm looking for is create the datastructure in file system, rather than in memory.

Thanks in Advance.

Nisha
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess a solution would depend on the shape of your hierarchy.
If there is some element X that is convenient for breaking the structure into small bits, you could write a new XML document for each X and track the filenames in memory. SAX events are convenient for this - you would start a new file everytime startElement got an X element.
Bill
 
Nisha Soorya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This solution would've been possible if the input xml files have the same schema.

But in my case input files will have different schemas. So I have to do the memory management at the data structure level.

Is there any way we can do it through object serialization?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yow! what an interesting problem. If you can't rely on a common schema to give you break points, is there anything regular in the structure of the XML that you can rely on?

I suppose you could represent a XML document as a sequence of these custom datastructure objects - if they are Serializable. What sort of processing are your users going to be doing to a document?
Bill
 
Nisha Soorya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basic operation I want to provide is to compare two xml files and display the changed nodes with different colors. then there could be renaming of some nodes, merging of nodes etc.

I created a datastructure where the children of each node is stored in a vector in that node... recursively .. so one xml file is converted in to one of such object.

The solution I'm looking for is, like when a user clicks on a node, load the immediate children of that node. But I'm not able to do that. And I found that serialization and deserialization is too slow if there are a large number of objects.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic