Hello,
Should the XmlValidatingReader validating xml against an xsd serially
(e.g. - does the XML have to be in the correct position in order for a
document to be valid)?
For example, I am trying to validate an xsd against a sample XML
document and receive errors indicating that there is an invalid child
node in my xml.
XmlValidatingReader complains of the following xml applied to the
following xsd:
<?xml version="1.0" standalone="yes"?>
<Sample xmlns="http://tempuri.org/Sample.xsd">
<Organizations>
<OrganizationID>1</OrganizationID>
<OrganizationName>CIBC</OrganizationName>
<CompanyID>1</CompanyID>
</Organizations>
</Sample>
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Sample" targetNamespace="http://tempuri.org/Sample.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://tempuri.org/Sample.xsd"
xmlns:mstns="http://tempuri.org/Sample.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Sample" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Organizations">
<xs:complexType>
<xs:sequence>
<xs:element name="OrganizationID" type="xs:int" />
<xs:element name="CompanyID" type="xs:int" minOccurs="0" />
<xs:element name="OrganizationName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Now, I know that the positions of companyid and organization name are
swapped. Should this detail necessarily fail the document? When I
apply the same schema to a dataset, the dataset loads properly.
Swapping the order of the elements to conform to the schema passes the
validation.
If this validator is sensitive to the position of elements, is there
any way to adjust for this such that the location of the elements is
not as important as the data types and occurances?
Thanks,
Alejandro