Unfortunately I'm still using 1.4... the Schema Factory is in 5.0.

Thanks

- Harjit

>From: "Edwin Dankert" <[EMAIL PROTECTED]>
>To: "H s" <[EMAIL PROTECTED]>
>CC: dom4j-user@lists.sourceforge.net
>Subject: Re: [dom4j-user] Validating against a schema
>Date: Mon, 25 Jun 2007 09:41:52 +0100
>
>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/

_________________________________________________________________
Get a preview of Live Earth, the hottest event this summer - only on MSN 
http://liveearth.msn.com?source=msntaglineliveearthhm


-------------------------------------------------------------------------
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
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to