Stax 2 1 validating Webcamcouples

Posted by / 01-Jun-2020 21:49

For the demo code I re-created the schema in simplified form: The header is neglectable in size.

A single data element repetition is also pretty small, lets say less less then 50k B.

What I understand from this is that its required for handling default namespaces.

Fact is that if it is not enabled the default namespace is not written in any way. Setting it does not actually write it to the stream.

Further more, the API's is a lot easier to use then SAX, because it pull based it gives more control on iterating the document and works more pleasant then the push way of SAX.

Aight, what do we need: The code is a bit to large to show it here as a whole.

On line 11-14 we use our JAXB generated model to create the header and let our JAXB marshaller write it directly to our St AX output stream.

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.

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.

It will also use JAXB to create our header and let it write to the output.