[xsd-users] Code generation fails for schemas with large maxOccurs values

Boris Kolpackov boris at codesynthesis.com
Tue May 13 08:01:52 EDT 2008


Hi David,

david.r.moss at selex-comms.com <david.r.moss at selex-comms.com> writes:

> No code is generated when maxOccurs="9957" or greater and when it's a
> smaller "large" number the code generation takes a very (very) long time.
> I realise that in general this is bad practise as XML validation is slow
> with large bounds as mentioned in this previous post:
>
> http://codesynthesis.com/pipermail/xsd-users/2007-February/000812.html
>
> but surely the code generation should still work - we may well be stuck
> with these schemas.

The XSD compiler uses Xerces-C++ underneath to validate the schemas
being compiled. As a result, the same problem with maxOccurs exists
when compiling a schema as when validating an instance against it.

At the moment the only work around for this problem that I can think
of is to change large maxOccurs values to unbounded. The generated
code is the same when maxOccurs > 1 and when it is unbounded.

You also need to do this if you need validation of the instance. In
this case you may have to enforce large maxOccurs constrains in the
application.

I will also check with the Xerces-C++ developers to see if there is
any chance of fixing this problem for the Xerces-C++ 3.0.0 release
(last time I checked it required some serious architectural changes).

Boris




More information about the xsd-users mailing list