Something strange with the node transformer

When I use the node transformer and setup a pattern, It ignores any pattern I set an just iterates over the next nodes.

For example:
If I setup the node transformer like this, I expect to set a new key/val pair under data2.Node1.test = test

But it will set the test/test key/val pair on the first node, even ignoring the data2 pattern:

Even if I just use data2 as only pattern it also puts the value in data.
So it looks to me that “pattern” does not do anything, it just moves to the next node:

Testcase transformer:

{
  "type": "transformer",
  "specification": {
    "prototype": "node",
    "parameters": {
      "nodeTransformers": [
        {
          "prototype": "value-setter",
          "parameters": {
            "configurations": [
              {
                "value": "test",
                "mappers": [],
                "key": "test"
              }
            ]
          }
        }
      ],
      "pattern": "data2"
    }
  }
}

Testdata transformer:

{
  "data": [
    {
      "Node1": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    },
    {
      "Node2": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    }
  ],
  "data2" : [
    {
      "Node1": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    },
    {
      "Node2": [
        {"data" : "data"},
        {"data" : "data"}
      ]
    }
  ]
}

Hi again Rick.

Yea i’ve ran into this problem aswell, and after my findings it seems like there is 2 different node transformers, one of them (The one you used) seems to work different than the other one. maybe someone can answer us what the difference is since i found this strange aswell.

I found this solution to work, start with the “Execute entity transformer” transformer and find “Node, transform nodes” inside, this one will do what you want.

Output:

2 Likes

Hi @Rickvzanden, @mko,

It’s correct that the Node Transformer doesn’t work as expected. We will discuss with the team whether the transformer is still needed.

Thanks, Martin for showing the workaround using “Node, transform nodes” under “Execute entity transformer”.

1 Like