cancel
Showing results for 
Search instead for 
Did you mean: 

XSD Validations

ranjit_deshmukh
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

ranjit_deshmukh
Active Participant
0 Kudos

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.

Answers (3)

Answers (3)

ranjit_deshmukh
Active Participant
0 Kudos

I have designed my own parser and created an error handler for it

so dont need to rely upon XI's error handler

Former Member
0 Kudos

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);

}

}

ranjit_deshmukh
Active Participant
0 Kudos

Sorry this doesnt help either

I used the same way except PrintWriter

I was using printStackTrace() method.

ranjit_deshmukh
Active Participant
0 Kudos

Is my question too difficult to answer?

no takers for this?