String xsdKeyValue = null;
String path;
SynapseXPath xpath;
// create a validate mediator
ValidateMediator validate = new ValidateMediator();
//default source, xsdFile, and state of key (dynamic or static)
String source = "";
String xsdFile = "";
boolean isDynamicKey = true;
// based on source, different xsdFiles can be used
if (num == 0) {
source = VALID_ENVELOPE;
xsdKeyValue = "xsd-key";
isDynamicKey = false;
xsdFile = "validate";
} else if (num == 1) {
source = DYNAMIC_KEY_ENVELOPE;
// xsdFile = "dynamic_key1.xsd";
xsdKeyValue = "DynamicXsdKey";
isDynamicKey = true;
xsdFile = "validate3";
}
if (isDynamicKey) {
// set the schema url using dynamic key (Xpath)
path = "//m0:CheckPriceRequest/m0:" + xsdKeyValue;
xpath = new SynapseXPath(path);
xpath.addNamespace("m0", "http://services.samples/xsd");
validate.setSchemaKeys(createKeyListFromDynamicKey(xpath));
} else {
// set the schema url using static key
validate.setSchemaKeys(createKeyListFromStaticKey(xsdKeyValue));
}