You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Ben Stover <bx...@yahoo.co.uk> on 2007/12/27 18:24:20 UTC
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: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Is there a command line validation with Xerces for XML doc against XSD schema ?
Posted by Dave Brosius <db...@mebigfatguy.com>.
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" <bx...@yahoo.co.uk>
To: <j-...@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: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
Re: Is there a command line validation with Xerces for XML doc against XSD
schema ?
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Ben,
There are many pre-compiled samples that ship with Xerces-J which can be
used from the command line to do what you want. Take a look at the docs
[1].
Thanks.
[1] http://xerces.apache.org/xerces2-j/samples-jaxp.html#SourceValidator
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
"Ben Stover" <bx...@yahoo.co.uk> wrote on 12/27/2007 12:24:20 PM:
> 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: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org