The world of XML Grammars is divided.
Not everything can be defined using a regular XML Grammar.
There is nothing wrong using a programming language to perform the validation.