Stax 2 1 validating
Important: the JAXB marshaller is initialized in fragment mode, otherwise it will start to add an XML declaration, as would be required for standalone documents, and that is of course not allowed in the middle of an existing document: On a side note: the JAXB integration is not really useful in this example, it creates more complexity and takes more lines of code then simply adding the elements using the XMLStream Writer.
However, in if you have a more complex structure which you need to create and merge into the document it is pretty handy to have automatic object mapping.
From here: St AX2 is an experimental API that is intended to extend basic St AX specifications in a way that allows implementations to experiment with features before they end up in the actual St AX specification (if they do).
As such, it is intended to be freely implementable by all St AX implementations same way as St AX, but without going through a formal JCP process.
The XML is so big because of the number of repetitions of the data element.
The requirements are that: So, using binary split tools such as Unix Split is out of the question.
It will also use JAXB to create our header and let it write to the output.
A single data element repetition is also pretty small, lets say less less then 50k B.
Therefore one needs write Default Namespace (line 9) but that can only be done after a start element has been written.
So, you have to define the default namespace before writing any elements, but you need to write the default namespace after writing the first element.
Last week I was asked to write something in Java that is able to split a single 30GB XML file into smaller parts of configurable file size.
The consumer of the file is going to be a middle-ware application that has problems with the large size of the XML.