cancel
Showing results for 
Search instead for 
Did you mean: 

Challenging Message Mapping Question

Former Member
0 Kudos

Hi,

I have a source XML:

<root>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

</itemB>

<itemA>

<id>2</id>

</itemA>

<itemA>

<id>3</id>

</itemA>

<itemB>

</itemB>

</record>

</root>

And, the target needs to look like:

<root>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

<id>1</id>

</itemB>

<itemA>

<id>2</id>

</itemA>

<itemA>

<id>3</id>

</itemA>

<itemB>

<id>3</id>

</itemB>

</root>

In summary:

1. (easy) an element "itemB/id" needs to be created only when "itemB" exists. In the target XSD, "itemB/id" is optional.

2. (hard or impossible) the value of "itemB/id" is equal to the "itemA/id" right before it in the source XML.

Is this possible?

Thanks in advance for any help,

Bill

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi William ,

Please confirm your data types .

If you have data types like this-

Source Data type

=================

<recordSet>1..1

<record> 1..unbounded

<itemA> 0..1

<id> 0..1

<itemB>0..1

<id> 0..1

Target Data type

==================

<recordSet>1..1

<record> 1..unbounded

<itemA> 0..1

<id> 0..1

<itemB>0..1

<id> 0..1

Then you can attain the target structure mapping you expected ..

Sample test data with source and target message types..

Please confirm this ..

Source Structure -

=================

<root>

<recordSet>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

</itemB>

</record>

<record>

<itemA>

<id>2</id>

</itemA>

</record>

<record>

<itemA>

<id>3</id>

</itemA>

<itemB>

</itemB>

</record>

</recordSet>

</root>

Target Structure -

=================

<root>

<recordSet>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

<id>1</id>

</itemB>

</record>

<record>

<itemA>

<id>2</id>

</itemA>

</record>

<record>

<itemA>

<id>3</id>

</itemA>

<itemB>

<id>3</id>

</itemB>

</record>

</recordSet>

</root>

Please let me know if you need any further information

Nanda

Former Member
0 Kudos

Hi Nanda,

Unfortunately, <itemA> and <itemB> are not grouped together by <record>. Pls see the original post.

I admit, this XML document does not conform to the spirit of the XML standard. It contains structure/hiearchial information which cannot be determined just by looking at the XSD.

But, this is the document created by the source system, with that embedded information. And, it cannot be changed.

Regards,

Bill

Former Member
0 Kudos

Really weird XML...

Can you give me your XSD of your XML?

MichalKrawczyk
Active Contributor
0 Kudos

hi,

what if you would take values to one array (assuming you have SP14 - global array) in UDF

and then in the table you'd have:

A has a value 1

B exits context change

A has a value 2

B does not exit nothing in the array

A has a value 3

so you would end up with

an array like:

1

context

2

3

then based on this I believe you could

create correct context changes in RECORD tag

(you can check the array - <b>if a context exists

fill itemB it with i = i -1</b> )

and fill them correctly in <itemA> and <itemB>

I didn't test it but maybe it could be possible ?

Regards,

michal

Former Member
0 Kudos

Hi Michael,

I need additional guide on this.

In Message Mapping, itemA and itemB are group individually. By examining the context/queue of itemB, I will not be able to determine its posiiton with respect to itemA. Unless, you have a way to group both itemA and itemB together keeping their positioning information.

Regards,

Bill

MichalKrawczyk
Active Contributor
0 Kudos

hi,

>>>>2. (hard or impossible) the value of "itemB/id" is equal to the "itemA/id" right before it in the source XML.

but you can do this

as you will have context (for B) and value (for a)

before it don't you think ?

unless I don't understand the problem which may also be a case:)

Regards,

michal

Former Member
0 Kudos

Hi Michael,

If I look at the queue of itemA, it contains the following:

-start-

[]

[]

[]

-end-

For itemB:

-start-

[]

[]

-end-

These information do not provided me with any ordering information between itemA and itemB. They are grouped individually.

Regards,

Bill

MichalKrawczyk
Active Contributor
0 Kudos

aaa you're right my bad:|

sorry then, my idea will not work

Regards,

michal