Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JaxB and unmarshalling  RSS feed

 
steve kelly
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey out there. So I am using Jaxb to pass in an xml file and doing the "createUnmarshaller()". Problem lies with the xml files being so huge that it takes forever just for the unmarshalling process. So the question is how do I "query" the process to see where it is in the process? I need to be able to see I am on 350 of 4000 records or whatever. Is this what the introspecter is for?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What variant of unmarshal() are you using?

In one project in the past, I had a similar problem. I solved it by using the variant which takes in XMLEventReader, which is part of StAX API.
Unlike DOM APIs, StAX does not need to receive the entire XML response to start processing it.

For progress, I implemented an Unmarshaller.Listener().

The combination of StAX and Listener allow both partial processing of XML stream as it comes in, as well as progress reporting (which you'll have to implement using a counter). However, I have some doubts whether you can know the total number of objects using this method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!