Use Class.getResource(String):
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getResource(java.lang.String)
Try the following:
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
URL url = getClass().getResource("/test.xsd");
Schema schema = schemaFactory.newSchema(
new StreamSource(url.openStream(), url.toString()));
factory.setSchema(schema);
SAXParser parser = factory.newSAXParser();
SAXReader reader = new SAXReader( parser.getXMLReader());
Document doc = reader.read("test.xml");
} catch (Exception e) {
e.printStackTrace();
}
Regards,
Edwin
--
http://www.edankert.com/
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user