on 2024 Aug 10 11:44 AM
I have a requirement to map a list of fields, and each value multiple times to target node.
Its similar like use Many as many function - compare with the standard function use one as many.
My source xml is like below:
<Root>
<id>123</id>
<items>
<itemId>1</itemId>
<references>
<code>c01</code>
<id>1</id>
</references>
<references>
<code>c01</code>
<id>2</id>
</references>
<subItem>
<subItemId>001
</subItemId>
</subItem>
<subItem>
<subItemId>002
</subItemId>
</subItem>
<subItem>
<subItemId>003
</subItemId>
</subItem>
</items>
<items>
<itemId>2</itemId>
<references>
<code>c01</code>
<id>3</id>
</references>
<references>
<code>c01</code>
<id>4</id>
</references>
<references>
<code>c01</code>
<id>5</id>
</references>
<subItem>
<subItemId>001
</subItemId>
</subItem>
<subItem>
<subItemId>002
</subItemId>
</subItem>
</items>
</Root>
and I want to map the each of the 'reference' node multuple times, the times equals the size of the subitem in source node.
Below are my expected target structure:
<Root>
<id>123</id>
<targetSubitem>
<itemId>1</itemId>
<references>
<code>c01</code>
<id>1</id>
</references>
<references>
<code>c01</code>
<id>2</id>
</references>
</targetSubitem>
<targetSubitem>
<itemId>2</itemId>
<references>
<code>c01</code>
<id>1</id>
</references>
<references>
<code>c01</code>
<id>2</id>
</references>
</targetSubitem>
<targetSubitem>
<itemId>3</itemId>
<references>
<code>c01</code>
<id>1</id>
</references>
<references>
<code>c01</code>
<id>2</id>
</references
</targetSubitem>
<targetSubitem>
<itemId>4</itemId>
<references>
<code>c01</code>
<id>3</id>
</references>
<references>
<code>c01</code>
<id>4</id>
</references>
<references>
<code>c01</code>
<id>5</id>
</references>
</targetSubitem>
<targetSubitem>
<itemId>5</itemId>
<references>
<code>c01</code>
<id>3</id>
</references>
<references>
<code>c01</code>
<id>4</id>
</references>
<references>
<code>c01</code>
<id>5</id>
</references>
</targetSubitem>
</Root>
Is there a way to do it with standard mapping funcion? Or must write UDF?
Thanks a lot in advance
User | Count |
---|---|
69 | |
10 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.