}
saveTracingState(xquery, queryMediator);
AXIOMXPath targetXPath = queryMediator.getTarget();
if (targetXPath != null &&
!XQueryMediator.DEFAULT_XPATH.toString().equals(targetXPath.toString())) {
xquery.addAttribute(fac.createOMAttribute(
"target", nullNS, targetXPath.toString()));
serializeNamespaces(xquery, targetXPath);
}
List pros = queryMediator.getDataSourceProperties();
if (pros != null && !pros.isEmpty()) {
OMElement dataSource = fac.createOMElement("dataSource", synNS);
serializeProperties(dataSource, pros);
xquery.addChild(dataSource);
}
List list = queryMediator.getVariables();
if (list != null && !list.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
Object o = list.get(i);
if (o instanceof MediatorBaseVariable) {
MediatorBaseVariable variable = (MediatorBaseVariable) o;
QName name = variable.getName();
Object value = variable.getValue();
if (name != null && value != null) {
OMElement baseElement = fac.createOMElement("variable", synNS);
baseElement.addAttribute(fac.createOMAttribute(
"name", nullNS, name.getLocalPart()));
baseElement.addAttribute(fac.createOMAttribute(
"value", nullNS, (String) value));
String type = null;
int varibelType = variable.getType();
if (XQItemType.XQBASETYPE_INT == varibelType) {
type = "INT";
} else if (XQItemType.XQBASETYPE_INTEGER == varibelType) {
type = "INTEGER";
} else if (XQItemType.XQBASETYPE_BOOLEAN == varibelType) {
type = "BOOLEAN";
} else if (XQItemType.XQBASETYPE_BYTE == varibelType) {
type = "BYTE";
} else if (XQItemType.XQBASETYPE_DOUBLE == varibelType) {
type = "DOUBLE";
} else if (XQItemType.XQBASETYPE_SHORT == varibelType) {
type = "SHORT";
} else if (XQItemType.XQBASETYPE_LONG == varibelType) {
type = "LONG";
} else if (XQItemType.XQBASETYPE_FLOAT == varibelType) {
type = "FLOAT";
} else if (XQItemType.XQBASETYPE_STRING == varibelType) {
type = "STRING";
} else if (XQItemType.XQITEMKIND_DOCUMENT == varibelType) {
type = "DOCUMENT";
} else if (XQItemType.XQITEMKIND_DOCUMENT_ELEMENT == varibelType) {
type = "DOCUMENT_ELEMENT";
} else if (XQItemType.XQITEMKIND_ELEMENT == varibelType) {
type = "ELEMENT";
} else {
handleException("Unknown Type " + varibelType);
}
if (type != null) {
baseElement.addAttribute(fac.createOMAttribute(
"type", nullNS, type));
}
xquery.addChild(baseElement);
}
} else if (o instanceof MediatorCustomVariable) {
MediatorCustomVariable variable = (MediatorCustomVariable) o;
QName name = variable.getName();
if (name != null) {
OMElement customElement = fac.createOMElement("variable", synNS);
customElement.addAttribute(fac.createOMAttribute(
"name", nullNS, name.getLocalPart()));
String regkey = variable.getRegKey();
if (regkey != null) {
customElement.addAttribute(fac.createOMAttribute(
"key", nullNS, regkey));
}
AXIOMXPath expression = variable.getExpression();
if (expression != null && !XQueryMediator.DEFAULT_XPATH.toString().
equals(expression.toString())) {
customElement.addAttribute(fac.createOMAttribute(
"expression", nullNS, expression.toString()));
serializeNamespaces(customElement, expression);
}
String type = null;
int varibelType = variable.getType();
if (XQItemType.XQITEMKIND_DOCUMENT == varibelType) {