String xsltKeyValue = null;
String path;
SynapseXPath xpath;
Value xsltKey;
XSLTMediator transformMediator = new XSLTMediator();
//default source, xsltFile, and state of key (dynamic or static)
String source = "";
String xsltFile = "";
boolean isDynamicKey = true;
// based on source, different XSLTFiles can be used
if (num == 0) {
source = SOURCE_STATIC_KEY;
xsltFile = "static_key.xslt";
xsltKeyValue = "StaticXsltKey";
isDynamicKey = false;
} else if (num == 1) {
source = SOURCE_DYNAMIC_KEY1;
xsltFile = "dynamic_key_1.xslt";
xsltKeyValue = "DynamicXsltKey1";
isDynamicKey = true;
} else if (num == 2) {
source = SOURCE_DYNAMIC_KEY2;
xsltFile = "dynamic_key_2.xslt";
xsltKeyValue = "DynamicXsltKey2";
isDynamicKey = true;
}
if (isDynamicKey) {
path = "//m0:CheckPriceRequest/m0:" + xsltKeyValue;
xpath = new SynapseXPath(path);
xpath.addNamespace("m0", "http://services.samples/xsd");
// Create key from dynamic key (xpath)
xsltKey = new Value(xpath);
// set XSLT transformation URL (Xpath)
transformMediator.setXsltKey(xsltKey);
} else {
//static key
path = xsltKeyValue;