wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes how to split a large xml file into smaller xml files ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to split a large xml file into smaller xml files ?" Watch "how to split a large xml file into smaller xml files ?" New topic
Author

how to split a large xml file into smaller xml files ?

Tiya Khambadkone
Ranch Hand

Joined: Sep 15, 2011
Posts: 52
how to split a large xml file into smaller xml files ?

Either using xslt or xpath or any other method ?
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Tiya,

Which parser you are goin to use? xpath can only use with dom.

Regards
jatan
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
I would consider using an SAX parser, simply writing the contents of events to a new file until it reached a good place to split. Then write the closing root element, close that file, open a new one, write the opening root element and continue copying.

Obviously you need to pay attention to the hierarchy and split only at a point that makes sense.

There may be a perfectly obvious way to do this with XSLT - not my field.

XPath has nothing to do with this problem.

Bill
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

William Brogden wrote:There may be a perfectly obvious way to do this with XSLT


In XSLT 1.0 (which most people are still using) it's only possible to write a single document as output. XSLT 2.0 provides ways of writing several documents from a single transformation, but it isn't built into the standard Java API.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to split a large xml file into smaller xml files ?
 
Similar Threads
split big DOM xml file ??
Problem preserving accented characters when writing text to file
splitting html file
nio package and memory mapped interface
"code too large for try statement " , While compiling JSP