on 11-12-2008 12:55 AM
Hi All,
I am trying to achieve the following using the graphical mapping tool.
Source:
Document..... 1-1
.....rows........ 0-unbounded
.........documentNumber.....1-1
Target:
Document.....1..1
..... header ....0-unbounded
..........documentNumber...1-1
......lines........0-unbounded
A sample source document is:
<Document>
...<rows>
.........<documentNumber>1</documentNumber>
...</rows>
...<rows>
.........<documentNumber>1</documentNumber>
...</rows>
...<rows>
.........<documentNumber>2</documentNumber>
...</rows>
</Document>
In the target structure, I want to create a header for each unique documentNumber. I have successfully done this using SplitByValue combined with collapse contexts, so that in the above example, I am creating two headers. However, my problem is that the documentNumber contained in those headers are both '1'.
What I need to achieve is two headers, the first one with documentNumber=1 and the second one with documentNumber=2.
Please help.
Regards,
JM
Hi All,
I have managed to solve this myself with a UDF of type 'Queue' to set the context of header:
public void createDocumentHeader(String[] uniqueDocumentNumbers, String[] allLineItems, ResultList result, Container container) throws StreamTransformationException{
int counter = 0;
boolean match = false;
for (int j = 0; j < allLineItems.length; j++)
{
match = false;
for (int i = 0; i < uniqueDocumentNumbers.length; i++)
{
if (uniqueDocumentNumbers<i>.equals (allLineItems[j]) && i==counter )
{
match = true;
//result.addValue(true);
counter++;
break;
}
}
if (match)
result.addValue(true);
else
result.addValue(false);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.