2

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).

3
  • 2
    For 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. Commented Feb 11, 2013 at 19:34
  • 2
    You could try fast infoset Commented 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? Commented Feb 13, 2013 at 1:42

1 Answer 1

2

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:

  1. Prefix with length of XML section
  2. XML section
  3. Binary section
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.