on 12-04-2006 12:53 PM
Hello all. I am working on a file - file scenario, XML - XML. My messages look as follows:
<u><b>Source:</b></u>
-<header> (1..unbounded)
---<field1>test</field1> (1..unbounded)
---<field2>test2</field2> (1..unbounded)
---<field3>1,2,3,4</field3> (1..unbounded)
-</header>
<u><b>Target:</b></u>
-<header> (1..unbounded)
---<field1>test</field1> (1..1)
---<field2>test2</field2> (1..1)
---<fieldTree> (1..unbounded)
-
<subField1>1</subField1> (1..1)
---</fieldTree>
---<fieldTree>
-
<subField1>2</subField1>
---</fieldTree>
---<fieldTree>
-
<subField1>3</subField1>
---</fieldTree>
---<fieldTree>
-
<subField1>4</subField1>
---</fieldTree>
-</header>
I have a UDF that creates the fieldTree contexts based on the number of items in field3 of source deliminated by comma. Another UDF to split the values and place into the subField positions.
That works fine, however when there are multiple entries of the source message, similar to:
<header>
<field1>test</field1>
<field2>test2</field2>
<field3>1,2,3,4</field3>
</header>
<header>
<field1>test3</field1>
<field2>test4</field2>
<field3>5,6,7,8</field3>
</header>
I receive this error:
<i>Cannot produce target element /ns0:test_XML/header[2]/fieldTree. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd</i>
If I disable the fieldTree field in target message it works fine. The mapping looks like this:
<u>target / source</u>
header / header
field1 / field1
field2 / field2
fieldTree / (UDF) field3
subField1 / (UDF) field3
My guess is it's something very simple that I am overlooking. Or some way that XI handles this sort of thing that I do not understand that could possibly be throwing errors at me. Anyone have any ideas to point me in the right direction?
I think you are missing the outerloop.Because when u are using two instances of the header..then it will be input[0] and input[1].Hope u understood what u meant,
It is not just input[0].split().but all the code has to have outer loop.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sravya, this makes a bit of sense. I had thought that XI would process and pull in the values procedurally, rather than pull all the values in ahead of time and then process them. I added an outer loop, and it didn't work. So I am trying to debug the issue and I changed the input[0] to input[1] and I got an error. So I believe that maybe it's not pulling in the second set of values from the second instance of field3. Could this be the case? How would I solve this issue?
yes,u can by accessing the length of input.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have u gone through this?
/people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i
/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My UDF for the fieldTree looks like this:
<i>String x[] = input[0].split(",");
for (int i = 0; i < x.length; i++) {
result.addValue(" ");
}
</i>
And the UDF for subField1 looks like this:
<i>String x[] = input[0].split(",");
for (int i = 0; i < x.length; i++) {
result.addValue(x<i>);
result.addContextChange();
}</i>
The first one creates the contexts and the second splits up the values in field3 of source message and places them into the contexts.
Message was edited by:
Harrison Holland
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.