[xsd-users] Handling of complex restrictions on types

Boris Kolpackov boris at codesynthesis.com
Thu Dec 3 09:17:31 EST 2015


Hi Jon,

Jon Winn <jon.k.winn at rrd.com> writes:

> Is it still the case that XSD does not and will not have runtime validation
> in the near future?

That's still correct.


> I face the same dilemma. This feature would benefit our application greatly!

I've spent a fair amount of time in the past years thinking about this
problem and the way I see it, it can be done in two different ways:

1. I "straightforward" implementation that will be pretty much unusable
   (as in "minOccurs says 1 and size is 0 -- throw; who cares the user
   hasn't had a chance to insert anything yet).

2. A more "thoughtful" implementation that will be some complex (and thus
   buggy) as to be unusable as well.

So I believe that in the "real world", the only approach that has a
realistic chance of working is to enforce as much of the schema as
possible via the static interface (so that an invalid instance is
impossible to make in the first place; a constructor with all the
non-optional members is a good example of this). And as for the rest,
the user will just have to be careful enough (and keep it simple),
just like in the rest of programming.

Boris



More information about the xsd-users mailing list