cancel
Showing results for 
Search instead for 
Did you mean: 

graphical mapping issue

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi JM,

I'm using XI 3.0, is could you please provide me details about the sort function in PI?

Regards,

Former Member
0 Kudos

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'

markangelo_dihiansan
Active Contributor
0 Kudos

Hi JM,

Please use the sort function with a case insensitive, ascending option for the Locations. Please let me know if this works.

Regards,

Edited by: dspboys on Nov 27, 2008 9:47 AM

Former Member
0 Kudos

No sorry, it still produced the same result:

No Locations created at all, and when I reverted to my original mapping of Locations but kept your Address mapping, only 1 Address was created per Location.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi JM,

I was able to send you my configurations through email.

Regards

Former Member
0 Kudos

the exact solution was provided above by dpsboys.. so removing my solution.

Edited by: Sarvesh Singh on Nov 27, 2008 4:05 PM

Former Member
0 Kudos

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

markangelo_dihiansan
Active Contributor
0 Kudos

Hi JM,

I was able to send my reply through email. Basically, you now have to use sortByKey for this one.

Regards,

Former Member
0 Kudos

Thanks dspboys, you are a mapping guru. Problem solved. Points awarded.

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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?

markangelo_dihiansan
Active Contributor
0 Kudos

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,