E4X Migration guide

The E4X extension for the native support of XML in JavaScript are progressively abandonned by Mozilla. Adobe Campaign heavily used this extension and so it is preparing to migrate to an alternative solution.

The aim of this guide is to help you migrate existing configurations or develop new configurations by describing the replacement solutions.

The old and new system co-exist, the currenct version of Adobe Campaign is always compatible with E4X but new configurations must not be developped with the E4X extension.

Reminder: E4X adds a type of JavaScript xml that can be built directly from the source program:

var doc = <xml> ... </xml>

or from a string:

var doc = new XML ("<xml>...</xml>")

It can then be manipulated with a specific API:

element.@id
element.where

XML type

The native "xml" type is replaced by a DOM API, these are DOMDocument , DOMElement , DOMNode types, ... the following is the equivalent of the most common operations:

E4X DOM
anElement.@id
anElement.$id
anElement.@["recipient-id"]
anElement["$recipient-id"]
anElement.childElement
anElement.getElements("childElement")
or
anElement.getFirstElement("childElement")

XML documents in a JavaScript must be replaced. When this document is to be used for a native function or an SOAP call passing an XML document in parameter, you can pass a JXON directly. This will be automatically transformed into an XML document (DOMDocument). If not, you can always pass via a JXON object, but an explicit conversion using the DOMDocument.fromJXON function is required.

var doc = DOMDocument.fromJXON({queryDef: 
{schema: "xtk:workflow", operation: "select",
  select: { node: {expr: "@internalName"} } 
}
})

Example of equivalence between XML and JXON syntax:

E4X JXON

              <queryDef schema="nms:delivery" operation="get">
  <select>
    <node expr="@created"/>
    <node expr="@lastModified"/>
  </select>
  <where>
    <condition expr="@id=123456"/>
  </where>
</queryDef>

              {queryDef: {schema: "nms:delivery", operation: "get", 
  select: {
    node: [
      {expr: "@created"}, 
      {expr: "@lastModified"}]
    }, 
  where: {
    condition: {expr: "@id=123456"}
  }
}}

For more information about JXON syntax, refer to the Using XML page.

SOAP Calls

These SOAP methods must run NLWS object properties. The schema's JavaScript ID is created from the namespace and the name starting with a capital. For example, the nms:delivery schema will have nmsDelivery as its JS ID.

Old New
nms.delivery.Play(deliveryId);
NLWS.nmsDelivery.Play(deliveryId);

SOAP JavaScript methods

To receive an XML document whose parameters are in the DOM format rather than E4X format, the dom="true" attribute must be added into the schema.

Multiline strings

Using XML to build multiline strings must be replaced by a concatenation of strings by forgetting to add the end of the \n line.

Old New
<str>line 1
line 2
line 3
</str>.toString()
"line 1\n" +
"line 2\n" +
"line 3\n"

Content management

It is necessary to activate the DOM option on the publication template or from the JavaScript template during the preview. For an XSL transformation with JavaScript pre-processing, you must also activate the DOM option (aggregator window).

JavaScript connectors

Add the following code to the script:
function isDOM()
{
  return true
}