Author |
Message
|
tom_1 |
Posted: Fri Feb 21, 2014 5:13 am Post subject: ESQL - copy subtree |
|
|
Newbie
Joined: 21 Feb 2014 Posts: 6
|
I have two different data structures in different NS, but fields in the subtrees are the same.
Structure 1: Source data - webservice
Structure 2: Destination data - IDOC
Structure 1 (source):
Code: |
Root
...
address
CITY
STREET
POSTAL_CODE
user
FIRSTNAME
LASTNAME
|
Structure 2 (destination):
Code: |
Root
...
customer_addr
CITY
STREET
POSTAL_CODE
contact
FIRSTNAME
LASTNAME
|
Of course I can copy each field from source to output,
but I have that structures with more than 20 fields.
Is there any way (pattern , procedure) in ESQL to do it more easily?
Regards
Tom |
|
Back to top |
|
 |
Esa |
Posted: Fri Feb 21, 2014 5:17 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Code: |
CREATE LASTCHILD of <reference> FROM <reference> |
|
|
Back to top |
|
 |
Gralgrathor |
Posted: Fri Feb 21, 2014 5:18 am Post subject: Re: ESQL - copy subtree |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
tom_1 wrote: |
Is there any way (pattern , procedure) in ESQL to do it more easily? |
Have you considered using a mapping node? Mapping nodes provide ways to easily map collections of fields with the same or similar names. |
|
Back to top |
|
 |
tom_1 |
Posted: Fri Feb 21, 2014 5:23 am Post subject: |
|
|
Newbie
Joined: 21 Feb 2014 Posts: 6
|
Esa wrote: |
Code: |
CREATE LASTCHILD of <reference> FROM <reference> |
|
Thank you , I wil check it
T. |
|
Back to top |
|
 |
Gralgrathor |
Posted: Fri Feb 21, 2014 5:23 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
Esa wrote: |
Code: |
CREATE LASTCHILD of <reference> FROM <reference> |
|
Doesn't that copy namespaces as well? |
|
Back to top |
|
 |
tom_1 |
Posted: Fri Feb 21, 2014 5:25 am Post subject: Re: ESQL - copy subtree |
|
|
Newbie
Joined: 21 Feb 2014 Posts: 6
|
Gralgrathor wrote: |
tom_1 wrote: |
Is there any way (pattern , procedure) in ESQL to do it more easily? |
Have you considered using a mapping node? Mapping nodes provide ways to easily map collections of fields with the same or similar names. |
Unfortunately I also have to do some complex transformations and conditions that I cannot do with MappingNode |
|
Back to top |
|
 |
Esa |
Posted: Fri Feb 21, 2014 5:32 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Gralgrathor wrote: |
Esa wrote: |
Code: |
CREATE LASTCHILD of <reference> FROM <reference> |
|
Doesn't that copy namespaces as well? |
Yes, it does, but changing namespaces recursively afterwards is quite straightforward. |
|
Back to top |
|
 |
tom_1 |
Posted: Fri Feb 21, 2014 5:46 am Post subject: |
|
|
Newbie
Joined: 21 Feb 2014 Posts: 6
|
Esa wrote: |
Gralgrathor wrote: |
Esa wrote: |
Code: |
CREATE LASTCHILD of <reference> FROM <reference> |
|
Doesn't that copy namespaces as well? |
Yes, it does, but changing namespaces recursively afterwards is quite straightforward. |
What about solution: procedure which setting fields in a loop (below)?
...
Code: |
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]); |
|
|
Back to top |
|
 |
Gralgrathor |
Posted: Fri Feb 21, 2014 5:54 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
FIELDVALUE returns scalar values only.
tom_1 wrote: |
Code: |
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]); |
|
The FIELDVALUE(elementA) of
Code: |
<ElementA><ElementB>Value</ElementB></ElementA> |
is NULL.
Last edited by Gralgrathor on Fri Feb 21, 2014 5:56 am; edited 1 time in total |
|
Back to top |
|
 |
kimbert |
Posted: Fri Feb 21, 2014 5:56 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
esa said:
Quote: |
Yes, it does, but changing namespaces recursively afterwards is quite straightforward. |
This is the correct answer. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
tom_1 |
Posted: Fri Feb 21, 2014 5:58 am Post subject: |
|
|
Newbie
Joined: 21 Feb 2014 Posts: 6
|
Gralgrathor wrote: |
tom_1 wrote: |
Code: |
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]); |
|
The FIELDVALUE(elementA) of
Code: |
<ElementA><ElementB>Value</ElementB></ElementA> |
is NULL. |
Sorry, should be:
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(inputStructure.*[I]); |
|
Back to top |
|
 |
Gralgrathor |
Posted: Fri Feb 21, 2014 5:59 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
Gralgrathor wrote: |
tom_1 wrote: |
Code: |
SET outputStructure.{FIELDNAME(inputStructure.*[I]} = FIELDVALUE(outputStructure.*[I]); |
|
|
Besides, I think that the above code would overwrite recurring elements in the source to the first element in the target. |
|
Back to top |
|
 |
|