how to validate a xml file with a xml schema file using java parsers
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kiran_manohar
Posted On:   Sunday, October 12, 2003 02:57 AM

hi,
i am having an xml file and a xml schema file, my problem is to first validate the xml schema file with the xml file. if there are parsers /api's which describe an xml schema it would be helpful for my project
Regards
Kiranmanohar

Re: how to validate a xml file with a xml schema file using java parsers

Posted By:   Christopher_Koenigsberg  
Posted On:   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.

About | Sitemap | Contact