0

I retrieve XPath from a database (via DSS) and I need to apply it to the body. Is this somehow possible?

To give an example, let's say I have this xml request

<custom>
    <id>24</id>
    <text>Some Text</text>
    <firstOccurId>123456</firstOccurId>
    <secondOccurId>654321</secondOccurId>
</custom>

I take ID (24) and call template, which will return

<replacements>
    <row>
        <value>ABCDEFG</value>
        <xpath>/*/custom/firstOccurId</xpath>
    </row>
    <row>
        <value>GFEDCDBA</value>
        <xpath>/*/custom/secondOccurId</xpath>
    </row>
</replacements>

now I need to apply xpath to request and change it's value, so the transformed request body looks like this

<custom>
    <id>24</id>
    <text>Some Text</text>
    <firstOccurId>ABCDEFG</firstOccurId>
    <secondOccurId>GFEDCDBA</secondOccurId>
</custom>

I tried both evaluate() and put XPath string inside {{}} in Call Template mediator, but both without success.

Community
  • 1
  • 1

1 Answers1

0

evaluate() is the correct answer. To be more specific, for this example I need to store custom request in property, get replacements, loop through them and inside this loop I need to store full xpath in property as fn:concat('$body', //el:row/el:xpath, '/text()'), enrich body with original payload and apply stored xpath as evaluate()