Hello,
I have wriite a mediator for validation, in my schema one <xsd:include> is also there.
I created two entries in Integrated Registry
Schema/s1/File.xsd - content of child schema file
Schema/s1/OutputMessage.xsd - content of parent schema file
Source validateSrc = SynapseConfigUtils.getStreamSource(synCtx.getEntry("Schema/s1/xmlFile"));
ArrayList<String> schemaKeys = new ArrayList<String>();
schemaKeys.add("Schema/s1/OutputMessage.xsd"); //parent xsd key from registry
// schemaKeys.add("Schema/s1/File.xsd"); - i tried using this also, but it is now working
// in OutputMessage.xsd - i am tried with giving "Schema/s1/File.xsd" as schemaLocation in the registry also but still no chance....
StreamSource[] sources = new StreamSource[schemaKeys.size()];
int i = 0;
for (String propName : schemaKeys) {
sources[i++] = SynapseConfigUtils.getStreamSource(synCtx.getEntry(propName));
}
cachedSchema = factory.newSchema(sources);
Validator validator = cachedSchema.newValidator();
System.out.println("===before validate()");
validator.validate(validateSrc);
System.out.println("===after validate()");
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
return false;
}
I am receivng the following error - essentially it is not resolving the child xsd file.
I have the respective files also...
---Krishna
| Attachment | Size |
|---|---|
| OutputMessage.xml | 252 bytes |
| File.xsd | 377 bytes |
| OutputMessage.xsd | 531 bytes |
It works for me , when I use shemas in a order ...
Hi
I was unable to give some help due to fact that we are really busy due to upcoming releases.
You never want to rewrite a validation mediator. There is a one in synapse (so …wso2 esb). Look at [1]. And if there are any issues or if it is needed to improve, it is great if you can provide patch for improving existing mediator without rewriting a new one.
I have tried your scenario with our existing mediator. You can set multiple schemas as you need using <schema key="string"/> in validate mediator.
Your scenario works for me when I add schemas in the order File.xsd , OutputMessage.xsd . But, when use reverse order, it doesn’t work (get error what you got). We use JAXP validation API and ‘xerces’ as provider. This may how ‘xerces’ works.
[1] http://synapse.apache.org/Synapse_Configuration_Language.html#validate
Thanks
Indika
my need is little different
Hello indika and asanka,,,,,
My requirement is little different. I don't want to give all the schema keys using - <schema key="string"/>...because if there are some 20 schema files then i can't give these files as schema keys and with tthat i need to take care of the order also...
So what i would like to do is as follows.
I will store all the required schema in the Integrated registry. and then I'll update schenaLocation with registry key of dependant files like- schemaLocation="REGISTRY_KEY_FOR_DEPENDANT_XSD" for the parent file with the key of child file
Now in my validation i will give only one schema file and rest of the dependant files should be resolved automatically by the validator. It is happening in simple java program i ran on file system( with using wso2)...but the same is not happening with wso2. where schema location is registry key.
thanks,
Krishna