I am generating some XML Schemas and would like to ensure that our generator is creating valid XML Schema documents (Not XML). I was trying to come up with the code to valid
I wouldn't validate an XSD using the approach you described for a couple of reasons, the most important one being that the XSD as a language is weak so in itself it does not capture the full spec. So, most likely, you may validate something that in fact is not valid.
For XSD validation you have specialized processors; Java has XSOM; follow the user guide.