Crossmap Activity

Crossmapping uses a simple Groovy-based DSL that enables you to expressively transform JSON/XML input documents to JSON/XML output documents.

Designing a Crossmap

Configuring a crossmap activity is as simple as selecting its mapper script and its input/output documents. You do this on the Design configurator tab in MDW Studio. The mapper script is the Groovy asset that performs the transformation. For input/output the dropdown lists include all document variables from your process. However, your selections must be from the supported JSON and XML types listed below. Note that one of the most powerful features of crossmaps is that they can map from JSON to XML and vice-versa using the exact same syntax. In other words, the input and output documents can have different flavors.

Supported input/output types:

How it Works

When the crossmap activity executes it automatically parses your input document using one of these Groovy Slurpers:

And it creates an empty instance of one of these Builders: The job of your mapper script is to build the output by pulling values from the parsed input. Here's an example that maps from the jsonInput variable to the xmlOutput variable:

xmlOutput {
    namespaces << [ns: 'http://www.centurylink.com/mdw']
    ns.game {
        ns.name 'chess'
        ns.currentChamp jsonInput.chess.champion
        ns.gameboard jsonInput.chess.board
    }
}

This examples also illustrates how namespaces can be incorporated into your MarkupBuilder output. It takes the following JSON input:

{"chess": {
  "board": {
    "columns": 8,
    "rows": 8,
    "shape": "rect"
  },
  "champion": "Deep Blue",
  "pieces": [
    {
      "movement": "diagonal",
      "name": "bishop"
    },
    {
      "movement": "two across, one over",
      "name": "knight"
    }
  ]
}}  

and produces this XML output (note that not every input property is mapped):

<ns:game xmlns:ns="http://www.centurylink.com/mdw">
    <ns:name>chess</ns:name>
    <ns:currentChamp>Deep Blue</ns:currentChamp>
    <ns:gameboard columns="8" rows="8" shape="rect"/>
</ns:game>