I have a Java program in which I have to validate an XML message against an XSD schema. So far so good. But now I got a new requirement where part of the validation is different based on the content of the XML message.
So based on the value of one field (1) some fields are nillable or not and some enumerations are different. However I can't parse the document before validation... so how should I cope with this?
1) Have 2 different XSD files, handle the XML as text (=ugly) and extract the one field to decide what XSD should be used?
2) Have 3 different XSD files. The 2 different options and one union so we can validate in a way that matches the 2 options? Than we can properly parse the XML, extract the field and decide which more specific XSD to use for extra validation?
3) Other options?