[xsd-users] Schema Validation

Boris Kolpackov boris at codesynthesis.com
Fri Oct 26 15:37:07 EDT 2007


Hi Shiva,

Balasubramanyam, Shivakumar <sbalasub at qualcomm.com> writes:

> Is there a document or guidelines for supporting schema validation using
> Code Synthesis.

For the C++/Tree mapping:

Section 5.1, "XML Schema Validation and Searching" in the C++/Tree
Mapping Getting Started Guide:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#5.1

For the C++/Parser mapping:

Section 5.3, "XML Schema Validation" in the C++/Parser Mapping Getting
Started Guide:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.3


> Here are some of the options that I see.
>
> 1.	Use xerces for validation and then code synthesis for XML
> de-serialization only

What you probably mean here is to perform XML-to-DOM stage yourself
(with enabled validation) and then use the DOM document as input to
the C++/Tree generated parsing functions.

You only need to use this approach if you want to pre-parse and/or
cache the schemas, as discussed in Section 5.1 mentioned above.


> 2.	Use Code Synthesis with schema validation that would require
> schema files.

This is the most commonly used approach and is discussed in detail
in Section 5.1.


> 3.	Use Code Synthesis with schema validation that would not require
> schemas but instead use the generated code to validate the document

The C++/Tree mapping provides only minimal support for XML Schema
validation in the generated code. C++/Parser, on the other hand,
support validation in the generated code of a commonly-used subset
of XML Schema. See Section 5.3 mentioned above for details.

We are also working on a new hybrid mapping which will be similar
to C++/Tree and will support validation in the generated code for
both parsing and serialization.


> If we are asked to use step 2, then what is the recommended way of
> provide the schema location and the url for the schema?

This is covered in detail in Section 5.1, "XML Schema Validation and
Searching" mentioned above.


> Another question is, if there is any difference between 1 and 2.

With option 1 you have more ability to customize the validation
parameters. Option 2 is simply the most commonly used setup.

Boris




More information about the xsd-users mailing list