[xsde-users] custom binary encoding

Jim Dattolo jdattolo at dekaresearch.com
Wed Dec 31 11:48:24 EST 2014


The attributes are used throughout the project where JAVA and Python are used as in both of those cases we use the attributes for hints on how to manage binary data as well as in filters.  Going back though things I now see that I need to manage the attributes even on the C side as the binary protocol has arbitrary length ints such as a uintle:3 (little endian 3 bit unsigned integer)  We don't use any optionals, everything is mandatory and everything is in a sequence for our system.  It sounds like I need to get into the compiler since I can't have any of the attributes being serialized.

-Jim


-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Tuesday, December 30, 2014 9:54 AM
To: Jim Dattolo
Cc: xsde-users at codesynthesis.com
Subject: Re: [xsde-users] custom binary encoding

Hi Jim,

Jim Dattolo <jdattolo at dekaresearch.com> writes:

> I want to encode my classes down to binary, however I want to strip off the
> attributes. [...] Is there any way to filter them out or add an option
> to the compiler to ignore attributes?

Customizing the XSD/e compiler is definitely possible but to me a much
easier way would be to strip the attributes from the schema (e.g., with
an XSLT transformation or some such). I may be wrong but from your
description it seems that the attributes in your schema are there
just for decoration. Their values are fixed and known to all the
parties involved.


> I see a lot of source for using the results of xsde, just not the
> source for the compiler itself?

It is right here:

http://codesynthesis.com/projects/xsde/


> Any pointers to start down this path?

Uh, the trickiest part will be building it, especially if you are
on Windows. In fact, if you do want to go down this path, it will
probably be better for you to start with the current pre-release;
the build system has been improved there somewhat. Customizing
the source code itself will be fairly easy.


> Also I need to change the endian order for the binary for all
> datatypes. Not all data types are setup in the raw stream
> code, is it as simple as overriding for all of the missing
> data types and changing the stream type to little endian?

Yes, the way you would want to handle this is to implement your
own binary representation streams, just like the 'binary/custom'
example.

One last note: you said that the binary protocol is fixed and
cannot be changed. While you can change how XSD/e serializes
basic types (integers, string, etc.; via the binary stream),
you cannot change how or in which order it serializes higher-
level constructs, such as optional/sequences of elements,
etc. For example, for an optional element, XSD/e will first
write a boolean flag and then the element itself. For a
sequence of elements it will write the count first followed
by all the elements. Things get less "standard" for choice,
for example.

So unless all of this happens to match your binary format, you
will run into trouble that would require further, potentially
significant, customizations of the XSD/e compiler.

Boris


 Click https://www.mailcontrol.com/sr/sfyoK8xrtljGX2PQPOmvUjg7ce8j6mWJ7fXiyPMP0Ma07o21biqxBeq3xJd77evTfRb1JLBUB+nCP4z!bwErJQ==  to report this email as spam.

This e-mail and the information, including any attachments it contains, are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.



More information about the xsde-users mailing list