My requirement is to have an XSD file which checks the elements based on attribute values. I was able to write XSD up to a point where I can restrict the attribute values of
Update: OP has edited question to remove the use of xs:assert and has stated in comments that validation must take place in C#. The answer to OP's question now becomes:
You cannot enforce a constraint that varies the requiredness of an element based on an attribute value using XSD 1.0, and Microsoft does not support XSD 1.1, therefore you must either relax your constraints or check them outside of your XSD.
(Retained for benefit of future readers)
You're close, but your assertion,
tests for @type on PackageArg when it should test for @Type on Application.
The following XSD will validate your XML and enforce your attribute-dependent requirements:
Be aware that Microsoft does not support XSD 1.1. (You've tagged your question with 'msxml').