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 Thomas Porschberg <th...@randspringer.de> on 2007/11/02 06:05:28 UTC
error check in sample SAXWriter
Hello Xercianer,
I have to validate a XML file against a XSD and tried the java version
of xerces for this task.
I simply installed Xerces (2.8) and the sample-jar and called
java sax.Writer -v -f -s foo.xml 1>/dev/null | grep Error
I'm not interested in the output. Because I'm on Unix I redirect
the output to /dev/null and I grep stderr for "Error" to detect
all kind of errors. If the return code of grep is 0 then the XML file
is not valid.
My questions:
1. Is there a better java-xerces "tool" for doing that task
(something like xmllint in java) ?
(I missed the possibility to suppress the output via a command line
switch.)
2. Is it reliable to grep for Error in stderr ? Are there situations there no
Error-line is printed but the XML is still corrupt ?
(The C++ version of Xerces comes with samples too and when I call
SAX2Print ... I'm able to detect validation/parse errors via the return code
of the program. This seems not the case with the java version.)
Best regards,
Thomas
--
http://www.randspringer.de
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: error check in sample SAXWriter
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Thomas,
The sample registers an ErrorHandler which prints every error reported to
it to System.err; each line prefixed with "[Fatal Error]", "[Error]" or
"[Warning]". If you grep for those you should catch every error / warning
emitted by the parser. The regular output from the sample is written to
System.out. You cannot suppress it unless you wrap your own program around
it which redirects the output elsewhere. There's no command line switch for
that.
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Thomas Porschberg <th...@randspringer.de> wrote on 11/02/2007 01:05:28 AM:
> Hello Xercianer,
>
> I have to validate a XML file against a XSD and tried the java version
> of xerces for this task.
> I simply installed Xerces (2.8) and the sample-jar and called
>
> java sax.Writer -v -f -s foo.xml 1>/dev/null | grep Error
>
> I'm not interested in the output. Because I'm on Unix I redirect
> the output to /dev/null and I grep stderr for "Error" to detect
> all kind of errors. If the return code of grep is 0 then the XML file
> is not valid.
>
> My questions:
> 1. Is there a better java-xerces "tool" for doing that task
> (something like xmllint in java) ?
> (I missed the possibility to suppress the output via a command line
> switch.)
> 2. Is it reliable to grep for Error in stderr ? Are there situations
there no
> Error-line is printed but the XML is still corrupt ?
> (The C++ version of Xerces comes with samples too and when I call
> SAX2Print ... I'm able to detect validation/parse errors via
> the return code
> of the program. This seems not the case with the java version.)
>
> Best regards,
> Thomas
>
> --
> http://www.randspringer.de
>
> ---------------------------------------------------------------------
> 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