I need to solve the following problem.
//pseudo algorithm
It's not possible in xml-schema. You can use a choice in combination with something like schematron:
Occurance rules an error message