The default for minOccurs
property of an <element>
in an XSD file is 1 (source).
Consider you have an XSD specifying a complex type containing 2 elements: <el1>
and <el2>
.
If you provide an XDocument
only containing <el2>
, the XDocument
will not validate.
Instead you'll get the message:
The element Message in namespace ___ has invalid child element el2 in namespace ___. List of possible elements expected: el1
This basically is an error on <el2>
where one would expect an error on the complex type for not containing <el1>
.
My question is:
Is there a way to check if all <element>
-tags which have minOccurs
> 0 are present?
I would say this is a very basic check when validating XML with an XSD.