[xsd-users] Re: Validation during serialization?

Boris Kolpackov boris at codesynthesis.com
Wed Jun 25 08:56:13 EDT 2008


Hi Ashok,

Ashok Nalkund <ashoknn at qualcomm.com> writes:

>   I am facing the exact problem that Timothy is facing. I tried to get 
> xsd to validate the object during serialization but no luck. Then I 
> found this post from last month on the users mailing list.
> 
> Do you have an idea when the validation for serialization would be 
> available?

We plan to have a C++/Tree-like mapping with support for validation
during serialization available in the next 3-4 months. However, it
will first appear in XSD/e, our embedded systems offering.

There is also a workaround for the C++/Tree mapping that you can use
in the meantime. It involves serializing the object model into XML
and re-parsing the result (perhaps only to DOM or even using SAX)
with validation enabled. One approach would be to serialize the
document into an in-memory buffer, re-parse it (possibly using DOM
or SAX parser for improved performance) to make sure it is valid,
and then write it to its final destination (e.g., a file).

Finally, you may also find the following post useful. It analyzes
possible use cases for in-memory or serialization-time validation
and comes to the conclusion that generally the application can't
really do anything about an invalid document except knowing that
it is invalid:

http://www.codesynthesis.com/pipermail/xsd-users/2008-January/001443.html

Boris




More information about the xsd-users mailing list