Skip to Content
0

UDF - Custom Index function

May 01 at 10:31 PM

39

avatar image

Hi experts,

I have a requirement to add indexing to the target field starting from the last index of a different node that is mapped to a different field.

My question is can anyone help me with a custom "Index" function where the starting number can be given as a input to the function rather than just specifying inside it.

Many thanks in advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Ramesh N May 02 at 08:57 AM
0

Anyone please?

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi ,

Can you just explore your query little bit more with help of desired xml output ?

Regards,

Dilip

0

Hi Dilip,

My input is:

Node 1 (1 ...1)

Node 1a (1 ....unbounded)

field1, field2

Node 2 (1 ...1)

Node 2a (1....unbounded)

field1, field2

Desired output:

Node A (1 to unbounded) and mapped to Node 1a of source

field1 - mapped to respective field of source

field2 - mapped to respective field of source

field3 - Index (mapped to Node 1a to get the index numbers based on the number of occurrences of Node 1a)


Node B (1 to unbounded) and mapped to Node 2a of source

field1 - mapped to respective field of source

field2 - mapped to respective field of source

field3 - Index (mapped to Node 2a) But here I want the index number to start from the last index of the previous node. For example, if in the source, Node 1a repeats 4 times and Node 2a repeats 3 times, I want the index of field3 in the Node B of target to start from "5"

Many thanks.

0

Hi,

Is it like this...

Input XML:

<input>
	<Node1>
		<Node1a>
			<field>x</field>
			<field>y</field>
		</Node1a>
		<Node1a>
			<field>x</field>
			<field>y</field>
		</Node1a>
		<Node1a>
			<field>x</field>
			<field>y</field>
		</Node1a>
		<Node1a>
			<field>x</field>
			<field>y</field>
		</Node1a>
	</Node1>
	<Node2>
		<Node2a>
			<field>x</field>
			<field>y</field>
		</Node2a>
		<Node2a>
			<field>x</field>
			<field>y</field>
		</Node2a>
		<Node2a>
			<field>x</field>
			<field>y</field>
		</Node2a>
	</Node2>
</input>

and output like

<output>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>4</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>4</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>4</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>4</field>
	</NodeA>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>5</field>
	</NodeB>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>5</field>
	</NodeB>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>5</field>
	</NodeB>
</output>

0

Hi Ramesh N

If above input/output is been correctly guessed, then you need two udfs (all queue):

  1. To count <Node1a> occurrence and pass it to <NodeA> 3rd field
  2. To count <Node1a> occurrence, increment by one and pass it to <NodeB> 3rd field

Regards,

Dilip

0

Hi Dilip,

The input is correct, but I want the output to be as below:

<output>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>1</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>2</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>3</field>
	</NodeA>
	<NodeA >
		<field>x</field>
		<field>y</field>
		<field>4</field>
	</NodeA>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>5</field>
	</NodeB>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>6</field>
	</NodeB>
	<NodeB>
		<field>x</field>
		<field>y</field>
		<field>7</field>
	</NodeB>
</output>


Node A occured 4 times, so it has the numbers 1,2,3,4. Node B should have the index starting from 5.

Thank you.
0
Priyanka Anagani May 09 at 02:07 PM
0

Hi Ramesh,

I'm not sure if this issue is resolved, thought of helping you out. See the attached mapping screens.

--Priyanka


capture1.png (20.1 kB)
capture2.png (25.1 kB)
capture3.png (19.7 kB)
capture4.png (32.7 kB)
capture4.png (32.7 kB)
capture5.png (17.6 kB)
capture6.png (23.8 kB)
capture7.png (32.3 kB)
Share
10 |10000 characters needed characters left characters exceeded