In my schema (xsd), I have an element with minOccurs=1, which I am treating as an required field and I want my application to make sure that field is provided by the clients in the xml. But how do I check for it explicitly. For example here is my element:
XSD:
xs:element minOccurs="1" maxOccurs="1" name="COL_FIRST_NAME" type="xs:string"/>
Xml:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Employee>
<FIRSTNAME />
</Employee>
</xs:schema>
If I need to validate this in my C# code is the hard check the only way? Like
if (FirstName=="")
{
Console.Write("The firstName cannot be empty");
}
Please note, I cannot use XmlReaderSettings.ValidationType. As my xml output is mapped with another Schema(xsd) for that I am using schema validation and it works well. But while writing the data to DB, I have another schema (the one I provided). This schema is to ensure that these specific elements are entered into DB without fail.