File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 12803
    
    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: 18655
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to split a large xml file into smaller xml files ?