473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Seek in huge xml-files

Hi all,

For a student project I have to be able to look up information in
xml-files that are several GB big. Depending on the input of the user
through the GUI data has to be displayed. And it's not applicable to
parse the whole file for every input. We can't use DOM since it would
load the whole file into memory. Our current approaches are based on the
use of SAX. We thought of generating some sort of index for every data
set that would provide us the byte offset in the file. The Project has
to be implemented in Java, so we wanted to do something like

Reader.skip(offsetBytes)

So we could jump to the location where our data set is without having to
parse the whole file. The Problem with that is, that we don't have any
idea on how to obtain the index information. How can you find out, where
in a file the SAX parser is (meaning the byte offset)?

Another point is that our tests with the SAX parser when skipping bytes
in it's input source produced this exception.

Content is not allowed in prolog

So we are wondering, whether it's possible to jump to some given
position and then parse from there.

I'm thankful for any advice since I'm quite helpless now. Many Thanks!
Bogomir Engel
Aug 8 '08 #1
2 2714
if it is less than 2GB and you have enough memory, try vtd-xml
http://vtd-xml.sf.net

"Bogomir Engel" <bo*****@grafidelity.dewrote in message
news:g7*************@news.t-online.com...
Hi all,

For a student project I have to be able to look up information in
xml-files that are several GB big. Depending on the input of the user
through the GUI data has to be displayed. And it's not applicable to parse
the whole file for every input. We can't use DOM since it would load the
whole file into memory. Our current approaches are based on the use of
SAX. We thought of generating some sort of index for every data set that
would provide us the byte offset in the file. The Project has to be
implemented in Java, so we wanted to do something like

Reader.skip(offsetBytes)

So we could jump to the location where our data set is without having to
parse the whole file. The Problem with that is, that we don't have any
idea on how to obtain the index information. How can you find out, where
in a file the SAX parser is (meaning the byte offset)?

Another point is that our tests with the SAX parser when skipping bytes in
it's input source produced this exception.

Content is not allowed in prolog

So we are wondering, whether it's possible to jump to some given position
and then parse from there.

I'm thankful for any advice since I'm quite helpless now. Many Thanks!
Bogomir Engel

Aug 11 '08 #2
We successfully completed the application.

javax.xml.stream.Location offers a method getCharacterOffset() which
does exactly what we needed.

This article was quite helpful:
Parsing XML documents partially with StAX
http://www.ibm.com/developerworks/xm...tx2/index.html

StAX is a very useful tool, when you don't have the memory to do it with
DOM and SAX offers insufficient control. For example one can decide how
to proceed in the parsing process at any time.

By the way, with some mapping JiBX (http://jibx.sourceforge.net/ very
recommendable) created ordinary Java objects out of the xml-data sets
for us. We saved the byte offsets in the objects during the initial
parsing process.
Sep 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Xenia | last post by:
Hello! Is anyone can help me to figure out how to write some xml into huge xml file into speceific location??? Say, i have a file about 139 Mb and i need to write some data (xml) into it, but...
15
by: Beda Christoph Hammerschmidt | last post by:
I wat to perform some performance measurements on an XML database. FOr this reason i need some huge XML sample data. The data should be not too structured and a lot of reasonable queries should...
1
by: Hakan Akkas | last post by:
Hello all, I need to build a search engine wherewith users can query huge Xml Documents (+/- 100 MB) in a user friendly way. The searcher shouldn't be aware of the underlying structure of the...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
11
by: Tiger | last post by:
We can use seek() in the FileStream class,as we know. But I found that seek() is not work correctly in StreamReader. Who can tell me how to use seek() correctly in StreamReader? thanks a lot! I...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
8
by: Sullivan WxPyQtKinter | last post by:
a relation database has admiring search efficiency when the database is very big (several thousands or tens of thousands of records). But my current project is based on XML, for its tree-like data...
4
by: busnet | last post by:
Hi. I've got the following problem: I have a huge xml-file that represents a street map of a city. Each street is stored as a couple of coordinates (start, end and all the turns). When I set a...
15
by: Sullivan WxPyQtKinter | last post by:
I have a huge log file which contains 3,453,299,000 lines with different lengths. It is not possible to calculate the absolute position of the beginning of the one billionth line. Are there...
0
by: Anthony Jones | last post by:
"DR" <softwareengineer98037@yahoo.comwrote in message news:ebCg7zR8IHA.1200@TK2MSFTNGP04.phx.gbl... of Please don't multi-post questions. The appropriate group would be the dotnet.general...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.