You apply rules like that using DTD alone. You would have to use #IMPLIED
in all attributes as suggested, and deal with that restriction in your code.
XML Schema 1.0 doesn't support that either, unless you use a standard extension such as Schematron, which allows assertions via XPath.
You can do that in XML Schema 1.1 using assertions (<xs:assert>
, very similar to Schematron, although you might have trouble finding a parser which supports it.