This is my code for validation of xml only problem i am having is in line 2 while importing org.apache.xerces…i downloaded xerces.jar and then added it as external jar into class from run configuration,can you just tell me if i am doing it write if yes then why this error if no then what should i do.
import java.io.File;
import org.apache.xerces.parsers.DOMParser;
public class SchemaTest {
public static void main (String[] args) {
File docFile = new File("C:\\Users\\ahussain\\Desktop\\Xml_Validation\\memory.xml");
try {
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty("http://apache.org/xml/properties/schema/external- noNamespaceSchemaLocation","memory.xsd");
ErrorChecker errors = new ErrorChecker();
parser.setErrorHandler(errors);
parser.parse("memory.xml");
} catch (Exception e) {
System.out.print("Problem parsing the file.");
}
}
}
Instead of adding to run configuration add the jar to your classpath,
Project – BuildPath – Configure Build Path – Libraries – Add your jar.