Building upon my question here, what would be the best way to combine a human-readable XML-like file format with a block of binary data? Would it be best to create two files (one XML-conformant linking to a second file with pure binary data) or maybe create a non-XML-conformant mixture of XML and binary data? Are there any such "mixtures" available (to avoid creating something completely proprietary)? What I want is to efficiently combine some human-readable data with vast amounts of data that do not need to be human readable but that need to be stored as efficiently as possible (as it could be Gigabytes of data).
-
2For smaller amounts of data you can include base64-encoded binary data to XML as text without problems. For large amounts of data the solution depends on particular usage scenarios (how the data will be created and accessed - it can be either an external reference from XML to the nearby binary file or it can be XML appended with binary data or whatever you can handle in your application.Eugene Mayevski 'Callback– Eugene Mayevski 'Callback2013-02-11 19:34:47 +00:00Commented Feb 11, 2013 at 19:34
-
2You could try fast infosetSami Korhonen– Sami Korhonen2013-02-11 19:35:17 +00:00Commented Feb 11, 2013 at 19:35
-
Is there a way to append a binary block as you suggested and still stay XML conformat e.g. by defining a length of the XML part of the document?ares_games– ares_games2013-02-13 01:42:30 +00:00Commented Feb 13, 2013 at 1:42
Add a comment
|
1 Answer
There is no standard way to do this but it is a simple idiom which I have seen several times.
Go with the non-conformant mix but with the aim to make it easy to read the entire XML block into a string and then parse from that string.
That maintains flexibility in allowing you to choose between most XML parsers.
So the file format I propose to enable quickly loading the XML block is:
- Prefix with length of XML section
- XML section
- Binary section