[xsd-users] Handling of complex restrictions on types
Yury Zaytsev
yury.zaytsev at traveltainment.de
Tue Apr 21 04:46:13 EDT 2015
Hi Boris,
Thank you very much for the clarification!
On Mon, 23 Mar 2015, Boris Kolpackov wrote:
>
> While some could argue that this is not the right way to handle it (i.e.,
> this is a "programming error", from the object model's point of view), I
> can also see why some might want this behavior. The good question to ask
> is what are you going to do when such an exception is thrown? In
> particular, there is almost certainly no way to automatically recover
> from it.
Well, my applications basically read and process the input data, open the
root element and some container element, and then stream serialized
elements of the same type one by one, finally closing the container
element and the root element.
So, from my perspective, there is a very clear way of handling such
exceptions: I would simply conclude that there is an issue with how I'm
filling the object model in, either due to invalid input that slipped
through my checks, or due to missing / incorrect business logic.
This means that I would just abort the attempt to emit this particular
element, log the information that would allow me to identify the problem
later, and happily continue processing the rest of the dataset.
Of course, the situation could be completely different (and not that
obvious at all) for other use cases...
> If you do decide to implement this yourself, you may want to check
> the type customization mechanism. This way you will be able to add
> the extra checks transparently wrt to the users of the object model.
For now, I opted to transform the input data in ways that it's going to be
less likely to cause problems, but, indeed, it's just a stop-gap solution.
Is this what you referred to (also in the enum thread):
http://wiki.codesynthesis.com/Tree/Customization_guide
So, the idea is basically to have XSD to generate base classes, and
inherit manually written ones implementing custom restrictions from those?
All the best,
--
Dr. Yury V. Zaytsev
Senior Software Developer
IT Data Production
TravelTainment GmbH
Carlo-Schmid-Straße 12
52146 Würselen/Aachen, Germany
yury.zaytsev at traveltainment.de
http://www.traveltainment.de
Amtsgericht Aachen, HRB 15873
Geschäftsführer: Bernhard Steffens (Vorsitzender),
Dr. Oliver Rengelshausen
More information about the xsd-users
mailing list