How to prevent XML prolog in JSON to XML policy

I'm using JSONToXML policy and i would like remove xml prologue before passing to next call.

1 1 175
1 REPLY 1

That thing you are calling the "prolog" is formally known as the XML declaration.

The feature you described - provide a way to omit that thing - has been previously requested. reference: b/65142394

It has been implemented, but has not yet been released to the public cloud.

As a result, for now, you need to post-process the message.content to remove the XML declaration manually, using an extra step. One way is via the ExtractVariables policy. Another is with text replacement in JavaScript. This latter might look like this;

<Javascript name='JS-RemoveXmlDeclaration' timeLimit='200' >
  <Properties>
    <Property name='xmldoc'>message.content</Property>
  </Properties>
  <Source>
var s = context.getVariable(properties.xmldoc),
    L = s.length,
    ix1 = s.indexOf('<?'),
    ix2;

if (ix1 > 0) {
  ix2 = s.indexOf('>');
  if (ix2 > ix1) {
    s = s.substring(ix2 + 1);
    context.setVariable(properties.xmldoc, s);
  }
}

</Source>
</Javascript>