[xsd-users] Parsing and validation from CDR stream
rc.mail.dev at gmail.com
Tue Aug 24 00:55:22 EDT 2010
Thanks for your reply.
Actually, I am going to use serialization with Boost Serialization (more
efficient in my case). In the example given, you are using a
boost::archive::text_oarchive to serialize the data:
using namespace library;
// Read in the file
std::auto_ptr<catalog> c (catalog_ (argv)));
cerr << *c << endl;
// Save into a text archive
text_oarchive oa (ostr);
xml_schema::ostream<text_oarchive> os (oa);
os << *c;
This implies that all the numeric values (int, double, float, etc.) will be
stored a sequence of characters. Let's take an example:
double var = 9.123456789 (number of characters/bytes = 11)
However, on x86 architecture, the representation of a double is 8 bytes.
Message sizing is one of my big concern.
Since Boost serialization provides a binary_oarchive, I was wondering if it
was possible to use this archive model with XSD?
Thank you for your help.
On Fri, Aug 6, 2010 at 9:24 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:
> Hi Romain,
> Romain <rc.mail.dev at gmail.com> writes:
> > One part of my application serializes C++ data to CDR. For what I
> > understand, there is no validation at this stage.
> That's correct.
> > The other part of my application receives the CDR data, deserializes the
> > to C++ data (also no validation at that stage correct?).
> Also correct.
> > That's why I need the validation, because there might be some invalid
> > (boundaries errors, etc.).
> Just to clarify, there cannot be CDR-related errors (that's what I assume
> you refer to by "boundaries errors") since the CDR insertion/extraction
> code is auto-generated from a valid schema. If you detect such errors
> then that means there is a bug in the XSD compiler.
> You can get an invalid object model after extracting it from CDR only if
> the object model that was saved to CDR on the other end was already invalid
> (e.g., an invalid XML file was parsed with validation disabled or an
> object model was created programmatically).
> > Any other suggestions on how I could handle this case?
> If you still need to validate the result of the CDR extraction then
> the only way is to serialize the object model to XML and then re-
> parse it with validation, as outlined in my previous email.
> If this doesn't work for you then you can take a look at the C++/Hybrid
> mapping in XSD/e. It also supports CDR streams and you can validate
> the object model during parsing and serialization. The idea is to
> run a validating serializer on the object model with no-op writer
>  http://www.codesynthesis.com/products/xsde/
More information about the xsd-users