[xsd-users] base64_binary compression

Boris Kolpackov boris at codesynthesis.com
Mon Sep 22 01:28:19 EDT 2014


Hi Andrej,

Andrej Vasilj <andrej_vasilj at hotmail.com> writes:

> I just started using xsd and I am really enjoying it.

Thanks, glad to hear that!


> However, in the mzML format I am currently working with there is a
> base64_binary entry which I would like to compress (either with
> zlib or something else). I do not immediately see how I can
> accomplish this. Does anybody know how?
> 
> When I create an instance of the binary_type, XSD automatically
> encodes my double * array to base64, and then automatically
> serializes it into the xml output. Is there anyway to intervene
> in this process and provide the already compressed base64 data?

You can accomplish this pretty easily with type customization. See
the C++/Tree Mapping Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

As well as the examples in the examples/cxx/tree/custom/ directory.

There are two ways that you can approach this: If it is all the
base64_binary elements/attributes in your vocabulary that you
want to compress, then you would customize base64_binary itself.

If, however, it is only a specific element/attribute of the
base64_binary type that you want compressed, then your would
customize the complex type that contains this element/attribute
and compress the data in the serialization operator and de-
compress it in the parsing constructor.

Finally, there is the 'compression' example that shows how
to compress the whole document with zlib.

Boris



More information about the xsd-users mailing list