on 10-15-2009 5:53 PM
Hello all,
I'm developing a PI adapter module (Exchange Infrastructure 3.0) for the Mail Adapter. In this module I need to get each XML attachment and then validate with an XSD schema, for this I'm using the SAX parser.
I successfully retrieved all XML attachments but when I'm trying to use the method setProperty of the SAXParser instance I'm getting an exception, bellow the code snippet.
private static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
private static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
private static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
public boolean isValid(byte[] src, AuditMessageKey amk1){
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = null;
spf.setNamespaceAware(true);
spf.setValidating(true);
String[] schemas = new String[MAX_SCHEMAS];
schemas[0] = getClass().getResource(SCHEMA1).getFile();
schemas[1] = getClass().getResource(SCHEMA2).getFile();
schemas[2] = getClass().getResource(SCHEMA3).getFile();
try {
sp = spf.newSAXParser();
}
catch (Exception e){
Audit.addAuditLogEntry(amk1, AuditLogStatus.ERROR, "MultipleAttachments: Error creating parser.");
return false;
}
// HERE IS THE STEP THROWING THE EXCEPTION
try {
sp.setProperty(SCHEMA_LANGUAGE, XML_SCHEMA);
}
catch (Exception e){
Audit.addAuditLogEntry(amk1, AuditLogStatus.ERROR, "MultipleAttachments: Error setting schema.");
return false;
}
Did Anyone have faced this issue? How can I solve this?
Best regards,
David
Hi David,
we developed a xsd validation with java mapping.
SAP has it's own parser. At the time we developed there was a bad bug in this parser. The parser throwed a fatal error although the xml was valid!
SAP corrected the error. But this is over 1,5 years ago. I recommend a OSS .
Regards Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.