Hello,
I'm having a problem when trying to use the XmlReader.Create(nodeReader,
settings) method to validate an XML document against a schema.
The problem is that if there are multiple missing required elements in the
document, the validation is only picking up the first one and none of the
others.
For example given the following schema and xml
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.mydomain.com/schemas/Organisation/v1.0.0"
xmlns:oi="http://www.mydomain.com/schemas/Organisation/v1.0.0"
xmlns:s="http://www.w3.org/2001/XMLSchema">
<s:element name="organisation" nillable="true" type="oi:organisationType" />
<s:complexType name="organisationType">
<s:complexContent mixed="false">
<s:extension base="oi:nodeType">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="trading-as"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="also-known-as"
type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="known-as" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="registered-as"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="previously-known-as"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="turnover-amount"
type="s:double" />
<s:element minOccurs="0" maxOccurs="1" name="turnover-range-code"
type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="employee-count"
type="s:int" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
</schema>
<?xml version="1.0" encoding="utf-8"?>
<oi:organisation
xmlns:oi="http://www.mydomain.com/schemas/Organisation/v1.0.0" >
<oi:trading-as />
<oi:previously-known-as>Flutterbys Inc</oi:previously-known-as>
<oi:turnover-amount>50</oi:turnover-amount>
<oi:turnover-range-code />
<oi:employee-count>5</oi:employee-count>
</oi:organisation>
The only thing it responds with is
"Validation Error: The element 'organisation' in namespace
'http://www.mydomain.com/schemas/Organisation/v1.0.0' has invalid child
element 'previously-known-as' in namespace
'http://www.mydomain.com/schemas/Organisation/v1.0.0'. List of possible
elements expected: 'also-known-as' in namespace
'http://www.mydomain.com/schemas/Organisation/v1.0.0'.,\r\n Error,\r\n
System.Xml.Schema.XmlSchemaValidationException: The element 'organisation' in
namespace 'http://www.mydomain.com/schemas/Organisation/v1.0.0' has invalid
child element 'previously-known-as' in namespace
'http://www.mydomain.com/schemas/Organisation/v1.0.0'. List of possible
elements expected: 'also-known-as' in namespace
'http://www.mydomain.com/schemas/Organisation/v1.0.0'.\r\n"
Which only indicates that one of the required elements is missing, even
though there are 3 reuiqred elements missing. How can I get the reader to
tell me all of the missing elements that need to be fixed?