-
In another thread, @odoodo provided a way to export the source code of a transformer. This post follows on that with two items:
Edit: Looked more closely. No longer a question. The first if else if is for the msg, the second is for the tmp. In the attached file, the core of the transformer is this JS: function doScript() {
msg = new XML(connectorMessage.getTransformedData());
if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; }
tmp = JSON.parse(template);
function filterRule1() {
// FILTER JS WAS HERE, REMOVED
}
}function doFilter() { phase[0] = 'filter'; return ((filterRule1() == true)); }
function doTransform() { phase[0] = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase[0]);
// TRANSFORM STEPS WERE HERE, JS REMOVED
if ('xml' === typeof msg) {
if (msg.hasSimpleContent()) {
msg = msg.toXMLString();
}
} else if ('undefined' !== typeof msg && msg !== null) {
var toStringResult = Object.prototype.toString.call(msg);
if (toStringResult == '[object Object]' || toStringResult == '[object Array]') {
msg = JSON.stringify(msg);
}
}
if ('xml' === typeof tmp) {
if (tmp.hasSimpleContent()) {
tmp = tmp.toXMLString();
}
} else if ('undefined' !== typeof tmp && tmp !== null) {
var toStringResult = Object.prototype.toString.call(tmp);
if (toStringResult == '[object Object]' || toStringResult == '[object Array]') {
tmp = JSON.stringify(tmp);
}
}
}
if (doFilter() == true) { doTransform(); return true; } else { return false; }
}
doScript(); My question is about the if else if statements below where the transformer code was. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@flugruger use code highlighting please, you know better :). |
Beta Was this translation helpful? Give feedback.
-
They are not duplicates. The first if/else statement operates on the |
Beta Was this translation helpful? Give feedback.
@flugruger use code highlighting please, you know better :).
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks
#4824