[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Reg Validation of xml
Hi I am pretty new to XML and I have a doubt about XML Doc. validation against a schema. I have a schema file in d:/jdk1.3/bin named sch.xml My xml file also resides in the same directory. I want to parse this xml file and validate it against my schema. The schema definition goes like this <Schema name="Root" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes"> .... .... <ElementType name="Root" content="eltOnly"> <AttributeType name="version" dt:type="float" required="yes"/> In my xml file i have the following <Root version="0.1" > .............. ........... </Root> We are using the xerces DOM parser from apache. In our code we have set the validation property to true. the code is like this class validate implements ErrorHandler { .... .... DOMParser parser=new DOMParser(); parser.setFeature("http://org.xml/sax/features/validation",true); .... ... } The error, fatalerror and warning methods of the ErrorHandler interface have been implemented. When i run the program it gives me an SAXParseException :" Element type "Root" must be declared." "Element type "ID" must be declared." etc. I feel my parser is not able to locate my schema for the purpose of validation. How do i specify the location of my xml schema file to the parser. How do i specify the url of urn:schemas-microsoft-com:xml-data in my xml file, the xsi attribute. My xml file is currently like this <?xml version="1.0"?> <Root version="0.1"> ............ .......... </Root> How do i specify the location of my schema(present in d:\jdk1.3\bin\) to my file. Do i need to implement any other thing. pls throw light on this with some examples Thanks in Advance
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|