on 10-23-2007 6:12 AM
Hi,
After refering the blog <a href="/people/morten.wittrock/blog/2006/03/21/validating-messages-in-xi-using-xml-schema messages using schema</a> I have created one scenario in which I do the validations on the incoming messagesto XI.
When there actually is no provision to do so-you have to handle this case explicitely. Thanks to Morten for his idea.
But there is a small problem I am facing in this approach-
I have successfully created the scenario, tested it, and its working fine.
But the problem is my Java code is giving up the parsing whenever the first error occurs.
i.e. if the message contains more no of error fields my program can show only the error that occured first, rest I can not see.
Well I think this explanation you will be able to understand,
please suggest any special exception handling techniques - presently I am using ErrorHandler class to handle exceptions.
Ranjit
hi,
the Blog Validating messages using schema you are following clearly states whenever error found it will stop executing further. So there you can do one thing... clearly design exception in java so that it can only throw at the end . can u please send ur java program
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for the reply Ajay
I am using the same code as u have given
and trying to impliment the same Idea(throwing at the end)
but it doesnt help
may be i think there is a different way that the XI engine handles the Exception
that is why when an error/exception is occured it throws it as StreamTransformationException and simply breaks the flow.
I have designed my own parser and created an error handler for it
so dont need to rely upon XI's error handler
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
can u code with following method and extend it with whatever u want
// Error handler to report errors and warnings
private static class MyErrorHandler implements ErrorHandler {
/** Error handler output goes here */
private PrintWriter out;
MyErrorHandler(PrintWriter out) {
this.out = out;
}
/**
Returns a string describing parse exception details
*/
private String getParseExceptionInfo(SAXParseException spe) {
String systemId = spe.getSystemId();
if (systemId == null) {
systemId = "null";
}
String info =
"URI="
+ systemId
+ " Line="
+ spe.getLineNumber()
+ ": "
+ spe.getMessage();
return info;
}
// The following methods are standard SAX ErrorHandler methods.
// See SAX documentation for more info.
public void warning(SAXParseException spe) throws SAXException {
out.println("Warning: " + getParseExceptionInfo(spe));
}
public void error(SAXParseException spe) throws SAXException {
String message = "Error: " + getParseExceptionInfo(spe);
throw new SAXException(message);
}
public void fatalError(SAXParseException spe) throws SAXException {
String message = "Fatal Error: " + getParseExceptionInfo(spe);
throw new SAXException(message);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is my question too difficult to answer?
no takers for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.