Facing issues with XML validation. My XML data look like this
<Sections>
<Section Id="DateAndTimeSection" Enable="True" >
<Column Id="Date" Format="YYYYMMDD" />
<Column Id="Time" Format="HHMMSS" />
</Section>
<Section Id="ComponentIdSection" Enable="True" >
<Column Id="ComponentId" Title="COUNTER" Enable="True" />
</Section>
</Sections>
I need to verify the XML document based on the "Id" attribute of the "Section" element.
If the Id value of the section is DateAndTimeSection then it should support Column's only with the Id's Date and Time. If any Columns other than the above are present ie. with Id value other than Date or Time it should be notified as an invalid XML.
Example: Valid XML
<Section Id="DateAndTimeSection" Enable="True" >
<Column Id="Date" Format="YYYYMMDD" />
<Column Id="Time" Format="HHMMSS" />
</Section>
Invalid XML
<Section Id="DateAndTimeSection" Enable="True" >
<Column Id="Date" Format="YYYYMMDD" />
<Column Id="Example" Format="YYYY" />
</Section>
I tried with the XML Schema and Schematron based validation.