Monday, October 13, 2003 07:01 AM
First in your subject heading you said you want to validate the xml file using the schema, but then in your actual question, you said you really first want to validate the schema itself? the schema file is just another xml document, so if that's what you mean, you can validate it too, against a dtd or another schema I guess. (I don't suppose anyone has worked on a "self-validating" schema which describes itself?...)
For just validating an ordinary xml document using a schema file, you just need to use a parser version that is recent enough to be schema-aware, so it has methods to tell it to use the schema instead of a dtd. Recent versions of Xerces from Apache can do this, for instance, but older ones can't.
(as we found when a j2ee app server which shall remain nameless, except that it was Weblogic 7.1, kept loading an older, non schema-aware version of the parser, in spite of our putting the latest one in a jar file in our war file)
And depending on your setup you might have headaches in trying to come up with the way to describe your schema file location in a URI, in such a way that you can package and deploy it, plus have the parser access it, e.g. the parser doesn't know anything about being in a web app context, etc., it just acts like a random web client, as far as its perspective on relative url's, virtual hostnames and clustering, firewalls, NAT'ted DNS, etc.