<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>hi,</FONT></DIV>
<DIV><FONT face=Arial size=2>try the following program..</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import org.xml.sax.InputSource;<BR>import
java.io.FileReader;<BR>import org.w3c.dom.Document;<BR>import
org.w3c.dom.Element;<BR>import org.w3c.dom.Node;<BR>import
org.w3c.dom.NodeList;<BR>import org.apache.xerces.parsers.*; <BR>import
org.apache.xerces.framework.*;<BR>import org.xml.sax.ErrorHandler; <BR>import
org.xml.sax.helpers.DefaultHandler; <BR>import org.xml.sax.XMLReader; <BR>import
org.xml.sax.SAXParseException;<BR>import org.xml.sax.SAXException;<BR>import
org.xml.sax.SAXNotRecognizedException;<BR>import
org.xml.sax.SAXNotSupportedException;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>public class ValidateWithSchema implements
ErrorHandler<BR>{<BR> public void
ValidateWithSchema()<BR> {<BR>
}<BR> public void warning(SAXParseException ex)
<BR> {<BR>
System.out.println("Warning");<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public void
error(SAXParseException ex) <BR>
{<BR>
System.out.println(ex.getLineNumber()+":"+ex.getColumnNumber()+": "+"Error is
:"+ex.getMessage());<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public void
fatalError(SAXParseException ex) throws SAXException <BR>
{<BR> System.out.println("Fatal
Error");<BR> }<BR> public static void
main(String argv[])<BR>
{<BR> ValidateWithSchema validate = new
ValidateWithSchema();<BR> XMLReader parser =
null;<BR>
try<BR>
{<BR> parser =
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();<BR>
}<BR> catch(Exception
e)<BR>
{<BR>
System.out.println("Error in
Instantiating");<BR>
}<BR> <A
href="file://parser.setContentHandler">file://parser.setContentHandler</A>(validate);<BR>
parser.setErrorHandler(validate);<BR>
try<BR>
{<BR>
parser.setFeature("http://xml.org/sax/features/validation", true);
<BR>
parser.setFeature("http://xml.org/sax/features/namespaces", true);
<BR>
parser.setFeature( "<A
href='http://apache.org/xml/features/validation/schema",true'>http://apache.org/xml/features/validation/schema",true</A>
);<BR>
parser.parse(new InputSource(new
FileReader(argv[0])));<BR>
System.out.println("Validation
:"+parser.getFeature("http://apache.org/xml/features/validation/schema"));<BR>
}<BR> catch(SAXNotRecognizedException
e)<BR>
{<BR>
e.printStackTrace();<BR>
System.out.println("False :Processing should be
stopped1");<BR>
}<BR> catch(SAXNotSupportedException
e)<BR>
{<BR>
e.printStackTrace();<BR>
System.out.println("False :Processing should be
stopped2");<BR>
}<BR> catch(Exception
e)<BR>
{<BR>
e.printStackTrace();<BR>
System.out.println("False :Processing should be
stopped3");<BR> }<BR>
} <BR>} // class </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>regds</FONT></DIV>
<DIV><FONT face=Arial size=2>anoop singh</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A href="mailto:kissg@freemail.hu" title=kissg@freemail.hu>Kiss Gábor</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
href="mailto:jdom-interest@jdom.org"
title=jdom-interest@jdom.org>jdom-interest@jdom.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, May 23, 2001 3:31
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [jdom-interest] W3C Schema
validation</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>How can I use schema validation with Xerces? Is
there somewhere a useful documentation or turorial about it?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I know it's not a real JDOM question, but I hope
I'll get an answer.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=Arial size=2>Gabor</FONT></DIV></BLOCKQUOTE></BODY></HTML>