[xsd-users] New feature

Boris Kolpackov boris at codesynthesis.com
Tue Sep 19 13:46:17 EDT 2006


Hi Deane,

Deane Yang <deane at kalotay.com> writes:

> Shouldn't it be possible to go the other direction and generate code that
> will convert the C++ objects into XML?

This questions can be interpreted in two different ways:

1. Can the objects generated from XML Schema (using C++/Tree mapping)
   be serialized to XML? The answer is yes. You will need to use the
   --generate-serialization option when translating your schemas. The
   library example in examples/cxx/tree/library shows how to do it.
   There is also a separate chapter on serialization in the manual.


2. Is it possible to automatically generate some code that will
   serialize arbitrary C++ object to XML? The answer is no, at least
   not with XSD.

   It is also seldom a good idea to do it this way. The main reason
   why you should choose XML is because it is universal enough and
   self-descriptive enough that other applications, perhaps written
   in other languages and running on other platforms, can parse and
   understand the information stored in it. In other words, it does
   not make sense to use XML (there are more efficient formats both
   to parse and space-wise) if it is only your application that is
   going to ever read it.

   Now if there are going to be other applications that will need
   to understand your XML-based format then you will probably need
   some formal specification for it. If your XML is written with
   the help of a tool that parses C++ objects and produces code
   to serialize them then those C++ objects are your specification:
   when they change your XML changes. Imagine now telling your
   other department (who, say, are using PHP) or, even better, your
   customer that they should read your C++ headers to figure out what
   the XML will look like ;-).


hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060919/aa740c21/attachment.pgp


More information about the xsd-users mailing list