[xsd-users] Extended validation in generated c++ code

Boris Kolpackov boris at codesynthesis.com
Wed Mar 28 12:13:37 EDT 2007


Hi Sergey,

In the future please keep the xsd-users mailing list CC'ed to your
replies. This way a) other developers who may have experienced a
similar problem can provide you with a solution and b) questions
and answers will be archived and available to others with similar
problems.


Sergey Tatarenko <sergey at hyperroll.com> writes:

> I want to add certain checks/validations which I can't do with xsd schema
> language.

I see now, thanks for clarifying this. There are two ways to achieve this
that I can think of. First is to simply write external code that will
perform the additional checks after the XML instance have been parsed
but before the resulting tree is used for further processing. You could,
for example, wrap the parsing function with your own code and instruct
the users to call it to obtain the tree.

A more elaborate approach would be to customize some of the generated
classes with the code that performs the additional validation. You could,
for example, customize the parsing constructors and add your own logic
after calling the standard parsing code. For more information on how
to customize the generated code, please see the C++/Tree Mapping
Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

There is also the wildcard example in the examples/cxx/tree/custom
directory that shows how to customize the parsing c-tor.

hth,
-boris


[The rest of the original email follows for context.]

> Here 2 major problems that I did'f find a way to eliminate by xsd schema
> rules:
>
> a) There is a type that have reference to items of the same type, and I want
> to check that a n object of that type is not referencing to itself. Or even
> more, there should not be cyclic references A->B->C->A
>
> b) Another problem is to check that if there is such a reference A->B, A has
> a reference to B. In a sequence that holds those objects B must appear
> before A

-------------- 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/20070328/881d7033/attachment.pgp


More information about the xsd-users mailing list