You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Valles Sánchez, Marcelino" <mv...@indra.es> on 2000/10/11 12:56:40 UTC

Document Validation

Hi,
I am new to Xml and i want to validate a document. I wrote de following code
but it doesn't work;
===================================================
import org.w3c.dom.Document;
import org.apache.xerces.parsers.DOMParser;
public class SimpleParse extends DOMParser {

	public SimpleParse (String nombreFichero)
	{
    	try 
	{
	    	this.setFeature( "http://xml.org/sax/features/validation",
true);
         	this.parse( nombreFichero );	
     	} catch ( java.io.IOException e ) {
        	System.err.println( "excepcion IO" + e );
     	} catch ( org.xml.sax.SAXException e ) {
        	System.err.println( "excepcion SAX" + e );
     	}
	} // constructor

    public static void main(String[] argv)
	{
        if (argv.length != 1)
		{
            System.err.println("A file name is required.");
            System.exit(1);
        }

      SimpleParse p = new SimpleParse( argv[0] );
      Document doc  = p.getDocument();
   	}
}
=================================================

What's going wrong?. Thank in advance.