tags:

views:

204

answers:

2

Can I express this in an XSD?

For example: One element is a required bool element named EmployedMoreThanThirteenWeeks and if the value is set to false I want the schema to require the existence of another element named EmploymentDate. And the other way around if the value is true then ideally the EmploymentDate element should be denied but I can accept it being optional.

A: 

No. An XSD just defines structure and data types, not relations. It is possible to add a key reference between elements but that won't prevent invalid nodes, just invalid values.

You can create an XSLT file (an XML Stylesheet) which will validate the XML file for you and thus generate a report of errors.

Workshop Alex
A: 

I think that XSD CANT do that, because the schemas verifies just an STRUCTURE (tree), and not VALUES (though you can check the value format). You should consider other validation ways.

eLZahR