on 11-27-2008 6:29 AM
Hi All,
I am trying to achieve the following using the graphical mapping tool.
Source:
rows..................0-unbounded
.....indicator1......1-1
.....indicator2......1-1
Target:
Locations...........0-unbounded
.....field1............1-1
.....Addresses.....0-unbounded
.........field2.........1-1
Sample Source xml:
<rows>
....<indicator1>M</indicator1>
....<indicator2>value1</indicator2>
</rows>
<rows>
....<indicator1>O</indicator1>
....<indicator2>value2</indicator2>
</rows>
<rows>
....<indicator1>O</indicator1>
....<indicator2>value2</indicator2>
</rows>
<rows>
....<indicator1>O</indicator1>
....<indicator2>value3</indicator2>
</rows>
In the target structure, I want to create a Locations where indicator1='O' and indicator2
is a unique value. Therefore, in the above example source document, the result should
be 2 Locations (due to indicator2 = value2 and value3). I have this part of the mapping
working.
My issue is that in the target structure, I also want to create an Addresses for every
group of <indicator2> with the same value and indicator1='O'. Therefore, based on the
above example source document, I need 2 Addresses in the first Locations (due to the
two rows of 'value2') and in the second Locations, I need 1 Addresses (due to the row
of 'value3). This is illustrated in the target document example below:
<Locations>
.....<field1/>
.....<Addresses>
.........<field2>value2</field2>
.....</Addresses>
.....<Addresses>
.........<field2>value2</field2>
.....</Addresses>
</Locations>
<Locations>
.....<field1/>
.....<Addresses>
.........<field2>value3</field2>
.....</Addresses>
</Locations>
Can I achieve this in the graphical mapping tool? If not, I will have to do it in xslt.
Please help!
Regards,
JM
Hi JM,
I'm using XI 3.0, is could you please provide me details about the sort function in PI?
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi dspboys,
In Pi 7.1 there are two sort functions - sort (sorts values in each context) and sortByKey (sorts values in second queue by keys from first queue)
Both sort functions have the following options:
1. Defines a Rule for Comparing Values - Options are 'case sensitive', 'case insensitive' or 'float number'
2. Defines Sort Order - Options are 'ascending' or 'descending'
Hi dspboys,
Yes sorry, I implemented it slightly wrong. I have now followed your screenshots and it is working great. However, I have now encountered an issue. Because I attempted to simplify my scenario, I think I have oversimplified it. If my source and target structures are as below:
Source:
rows..................0-unbounded
.....indicator1......1-1
.....indicator2......1-1
.....fieldA............1-1
Target:
Locations...........0-unbounded
.....field1............1-1
.....Addresses.....0-unbounded
.........field2.........1-1
Note, the source structure has a new field called fieldA.
If I follow your suggestions to map Locations and Addresses, how then do I map fieldA to field2? There is no pattern to fieldA. It is just a random value.
Regards,
JM
Hi ,
Try using Spilltbyvalue with option 'changed value' for the field <indicator2> and assign it to Address element.
<indicator2>-->SpllitbyValue(Value changed)---->Address
Regards,
Ganesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganesh and dspboys,
Neither of these suggestions worked.
Ganesh: With your suggestion, only 1 Address was being created for each of the two
Locations.
dspboys: The Locations mapping didn't map at all. Then when I reverted to my original
Locations mapping, and tried your Address mapping, I also just got 1 Address being created
for each of the two Locations. One question though - in the sort function, I did not have an
option to sort LexicographicalAscending. I'm using PI 7.1, so I selected the option 'Case
Sensitive' and 'Ascending'
Was I supposed to change the context for any of the elements used in both of your suggested mappings?
Hi JM,
Please use the mapping below:
for the target node Locations:
indicator1 equalsS constant:O --> ifWithoutElse with indicator2 --> removeContext --> sort:LexicographicalAscending --> SplitByValue:ValueChanged --> collapseContext --> Locations
for the target node Addresses:
indicator1 equalsS constant:O --> ifWithoutElse with indicator2 --> removeContext --> sort:LexicographicalAscending --> SplitByValue:ValueChanged --> Addresses
for the target node field2:
indicator1 equalsS constant:O --> ifWithoutElse with indicator2 --> removeContext --> sort:LexicographicalAscending --> SplitByValue:EachValue --> field2
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.