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.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: how to split a large xml file into smaller xml files ?