cancel
Showing results for 
Search instead for 
Did you mean: 

Context changes to a counter variable

ravi_raman2
Active Contributor
0 Kudos

SDN gurus,

any thoughts on how to go for this..

Input Structure

Node A

NodeB

NodeB

NodeB

Node A

Node B

Target

Node A

Node B

1

Node B

2

Node B

3

Node A

Node B

1

Has to be a udf, as the standard function ...counter..doesent support context changes.......thoughts on this ..?

Regards

Ravi Raman

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ravi,

Please refer to globalCounter() UDF described [here|http://www.riyaz.net/blog/index.php/2008/05/20/xipi-convert-flat-file-to-deeply-nested-xml-structures-using-only-graphical-mapping/].

This function has no arguments. In your case, you can pass the actual node (node B in your case) and the context of the parent node (node A in your case) as arguments. Also, cache the entire queue. Then loop through the input and reset the counter at every context change, while incrementing it if there is no context change. You can compare the input with constant ResultList.CC to identify the context changes.

Hope this helps.

Regards,

Riyaz

Former Member
0 Kudos

Please specify the source and target data types clearly...

Former Member
0 Kudos

Your requirement is not clear. Can you give a test src XML and expected target XML.

BR

Former Member
0 Kudos

Hi,

Let me know if I have understood correct.

If you have multiple NodeA and multiple NodeB in source structure where NodeB is child of NodeA

NodeA

NodeB

NodeB

NodeB

NodeA

NodeB

and if you want output as

NodeA

NodeB 1

NodeB 2

NodeB 3

NodeA

NodeB 1

This you can do using index function.

Thanks,

Beena.

ravi_raman2
Active Contributor
0 Kudos

Beena,

Maybe i should be clearer

for each node A i have 2 target fields each that should have same number....then count is incremented again...and reset...at next occurence

index function..didnt work..going the UDF way..

Ravi Raman