This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Tiya Khambadkone
Ranch Hand
Posts: 114
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to split a large xml file into smaller xml files ?

Either using xslt or xpath or any other method ?
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 22502
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!