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

Rizzuto, Raymond Raymond.Rizzuto at sig.com
Fri Jan 23 14:29:49 EST 2009


Boris,

Our schema is pretty complicated, with a lot of polymorphism.  I would hate to have to hand-write the C# code to deserialize the XDR.

One option might be to create a C++ library from the XSD generated code, and then link that into the C# application.   I believe that is possible, though I haven't done it myself.

Ray

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Friday, January 23, 2009 2:08 PM
To: Rizzuto, Raymond
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Efficient XML Interchange Format (Exi)

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

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.




More information about the xsd-users mailing list