[xsd-users] Efficient XML Interchange Format (Exi)

Boris Kolpackov boris at codesynthesis.com
Fri Jan 23 14:08:17 EST 2009


Hi Raymond,

[I've CC'ed xsd-users to my reply in case someone else is/will be
 interested.]

Rizzuto, Raymond <Raymond.Rizzuto at sig.com> writes:

> I was leaning towards EXI since it is from W3C, and should at 
> some point be a recommendation.  I was able to find a tool for
> .Net that says it supports it, which would simplify interoperability.
> 
> Do you have any documentation on the mapping from XML to CDR and XDR?
> I.e. so we could implement the matching deserialization on the other 
> end?

The binary serialization is actually quite simple. The basic types
(e.g., ints, strings, etc.) are serialized according to the data
representation rules. For CDR, see ace-cdr-stream-*-.hxx files
in libxsd/xsd/cxx/tree/. For XDR, see xdr-stream-*-.hxx files. I
think there is a better chance you will find XDR implementation 
for C# than CDR.

User-defined types a serialized like this:

1. If there is a base, it is serialized first.

2. Then elements are serialized in the schema order:
  
   a. For required elements, the element value is serialized directly.
   
   b. For optional elements a boolean value is serialized first
      indicating whether the element is present, then element
      value, if present.

   c. For sequences of elements, the number of elements is written
      first, then each element value in order.

3. Then attributes are serialized in the schema order (same rules
   as 2.a and 2.b).

If polymorphism is involved, things are a bit more complicated. For
every non-fundamental C++ type, first a boolean value is written
indicating whether this element's dynamic type differs from its
static type. If it does, then the dynamic type's namespace and name
are written. Then the value is serialized.

Actually, I think it should be pretty straightforward to extend XSD 
to automatically generate this code for C# classes. Maybe using
partial classes or some such.

Boris




More information about the xsd-users mailing list