metafacture-core icon indicating copy to clipboard operation
metafacture-core copied to clipboard

Metamorph: dynamic values for name attributes possible?

Open guenterh opened this issue 9 years ago • 7 comments

  • In between we use dynamic values (regularly taken from values of the same record) to create the name of new elements for the target record. Here you can find an example for this
  • My question: Is this possible with Metamorph? Do you have an idea what has to be done to get something similar with Metamorph / Metafacture mechanisms?

Thanks for any response!

Günter

guenterh avatar Dec 20 '15 19:12 guenterh

Hi Günter,

there are a number of ways to generate literal and entity names from the data values received.

  • The easiest is to use <combine>. It allows you to use variables in the name attribute in the same way as in the value attribute:
<combine name="${NAME}" value=${VALUE}">
  <data source="name-source-field" name="NAME" />
  <data source="value-source-field" name="VALUE" />
</combine>
  • To dynamically set the name of an entity you can use the <entity-name> statement:
<entity>
  <entity-name>
     <data source="name-source" />
  </entity-name>
  <data soource="entity-contents" />
</entity>
  • And finally, there is the <switch-name-value> function which can be used in data statements to swap name and value of the currently processed literal. It allows you to access the literal name and also to manipulate the name of the generated literal. It is a bit complicated to use though:
<data source="021A.p">
 <switch-name-value />
</data>

If this statement receives the literal 021A.p=Personalname, it will output Personalname=021A.p.

<data source="021A.p">
 <constant value="foo" />
 <switch-name-value />
</data>

Receiving the same literal as above, this statement will produce the output foo=021A.p. It first set the output value to foo and than changes name and value, so foo becomes the new name and 021A.p the value.

I hope, this helps. If you need more examples for the <switch-name-value> statement, let me know.

Best, Christoph

cboehme avatar Jan 07 '16 10:01 cboehme

Hello @guenterh, could you solve your issue following these hints? Then you could close the issue.

dr0i avatar Nov 18 '16 15:11 dr0i

I think @cboehme answered this question sufficiently and we can use this in out documentation.

dr0i avatar Dec 09 '21 08:12 dr0i

I think @cboehme answered this question sufficiently and we can use this in out documentation.

I moved this ticket since it was residing in documentation and was not related to the documentation repo. If this ticket is answered well enough we can close it.

TobiasNx avatar Dec 13 '21 12:12 TobiasNx

documentation and was not related to the documentation repo.

hm, I could have thought to collect scenarios and questions of users with a receipt to solve those. Wouldn't that be good for the documentation?

dr0i avatar Dec 13 '21 13:12 dr0i

If so then this example should be part of the cookbook and no open issue.

TobiasNx avatar Dec 13 '21 13:12 TobiasNx

Yes - someone has to transfer the helpful content to the cookbook :)

dr0i avatar Dec 13 '21 14:12 dr0i