javascriptmirth

Please help me understand one line of code


I've inherited a series of mirth channels that I need to modify but don't understand everything that has been done.

Yes, I could rewrite them 'my way' but time is short so, if anyone can explain what some of the code does that might be a real life saver.

The code I have inherited makes extensive use of '*::' (see example below).

tmp.*::['Body'].*::['SavePathologyResults'].*::['request'].*::['PathologyResults'].*::['SavePathologyResultRequest'][index] = newWCFNode;

While I get a general feel from this, what exactly does '*::' mean/do?

Thanks in anticipation...

(For context, 'tmp' is an XML SOAP envelope)


Solution

  • In E4X (ECMAScript for XML), :: is the syntax for qualified identifiers (11.1.2). *::['Body'] (or the equivalent *::Body) is the Body identifier in any namespace (11.1.3). Accessing it as the property of an XML or XMLList object means getting a new XMLList of all children with that identifier as a node name (11.2.1).

    So, that statement gets <Body> elements in tmp, then <SavePathologyResults> elements in those <Body> elements, then …, then <SavePathologyResultRequest> elements in those <PathologyResults> elements, and replaces the indexth <SavePathologyResultRequest> with newWCFNode (11.6.2) – where all of the aforementioned (and aforeunmentioned) elements could belong to any namespace.