Hmmm, Is this a trick question? Isn't this really just the hello world of 
xerces?
Something like


import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;


public class XV 
{
    public static void main(String[] args)
    {
        try
        {
            if (args.length != 2)
            {
                System.out.println("Incorrect arguments");
                System.out.println("parameters: xml-file xsd-file");
            }

            XMLReader r = XMLReaderFactory.createXMLReader();
            r.setErrorHandler(new ErrorHandler()
            {

                public void error(SAXParseException arg0) throws SAXException 
                {
                    System.out.println("error: " + arg0.getMessage()); 
                }

                public void fatalError(SAXParseException arg0)
                    throws SAXException 
                {
                    throw(arg0);
                }

                public void warning(SAXParseException arg0) throws SAXException 
                {
                    System.out.println("warning: " + arg0.getMessage());
                } 
            });
            r.setFeature("http://xml.org/sax/features/validation";, true);
            r.setFeature("http://xml.org/sax/features/namespaces";, true);
            r.setFeature("http://apache.org/xml/features/validation/schema";, 
true);
            
r.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,
 args[1]);

            r.parse(new InputSource(args[0]));
            System.out.println(args[0] + " was succesfully validated against 
schema " + args[1]);

           }
            catch (Exception e)
            {
                e.printStackTrace();
            }
    }
}
----- Original Message ----- 
From: "Ben Stover" <[EMAIL PROTECTED]>
To: <j-users@xerces.apache.org>
Sent: Thursday, December 27, 2007 12:24 PM
Subject: Is there a command line validation with Xerces for XML doc against XSD 
schema ?


>I wonder wether there is a way to call Xerces directly from the command line 
>in order to validate a  XML doc
> against an (external) XSD schema file.
> 
> Can I do this (with either C++ or Java Xerces) ?
> 
> It seems to me that Xerces is created only for usage calls from Java/C++
> 
> If yes: where are the command line options listed?
> 
> If not: Maybe someone wrote a short and simple wrapper program which enables 
> command line access for validations?
> Does such (short !) program (for WinXP) exist ?
> 
> Thank you
> Ben
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

Reply via email to