|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
Anonymous mixed content xml mapping |
« View previous topic :: View next topic » |
Author |
Message
|
Fayaz |
Posted: Wed Aug 24, 2011 7:55 am Post subject: |
|
|
Novice
Joined: 21 Jul 2011 Posts: 18
|
I thought I did it above but here it is:
My resultsets are as below:
Code: |
Col1 Col2 Col3 Col4 Col5
1 English Title - en 7 Blue - en
1 French Title -fr 7 Blue- fr
1 German Title -de 7 Blue - de
1 English Title - en 21 Black - en
1 French Title -fr 21 Black - fr
1 German Title -de 21 Black - de |
I need to map it to an xml like below:
Code: |
<ContentMaster>
<Entry>
<Col1>1</Col1>
<Col3 Col2="English">Title - en</Col3>
<Col3 Col2="French">Title - fr</Col3>
<Col3 Col2="German">Title - de</Col3>
<Entry1>
<Color Col4="7">
<Col5 Col2="English">Blue - en</Col5>
<Col5 Col2="French">Blue - fr</Col5>
<Col5 Col2="German">Blue - de</Col5>
</Color>
<Color Col4="21">
<Col5 Col2="English">Black - en</Col5>
<Col5 Col2="French">Black - fr</Col5>
<Col5 Col2="German">Black - de</Col5>
</Color>
</Entry1>
</Entry>
</ContentMaster> |
With the mapping node I have defined now I am getting the following resultsets:
Code: |
<ContentMaster>
<Entry>
<Col1>1</Col1>
<Col3 Col2="English">Title - en</Col3>
<Col3 Col2="French">Title - fr</Col3>
<Col3 Col2="German">Title - de</Col3>
<Col3 Col2="English">Title - en</Col3>
<Col3 Col2="French">Title - fr</Col3>
<Col3 Col2="German">Title - de</Col3>
<Entry1>
<Color Col4="7">
<Col5 Col2="English">Blue - en</Col5>
<Col5 Col2="French">Blue - fr</Col5>
<Col5 Col2="German">Blue - de</Col5>
</Color>
<Color Col4="21">
<Col5 Col2="English">Black - en</Col5>
<Col5 Col2="French">Black - fr</Col5>
<Col5 Col2="German">Black - de</Col5>
</Color>
<Color Col4="7">
<Col5 Col2="English">Blue - en</Col5>
<Col5 Col2="French">Blue - fr</Col5>
<Col5 Col2="German">Blue - de</Col5>
</Color>
<Color Col4="21">
<Col5 Col2="English">Black - en</Col5>
<Col5 Col2="French">Black - fr</Col5>
<Col5 Col2="German">Black - de</Col5>
</Color>
</Entry1>
</Entry>
</ContentMaster> |
I am using a $db:select:db.dbo.Table_col1 = 1 and looping it through a "for = $db:select" below my entry tag, my issue is occuring in the mixed content xml where I can't seem to eliminate duplicates...hope this helps. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 24, 2011 8:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Fayaz wrote: |
I am using a $db:select:db.dbo.Table_col1 = 1 and looping it through a "for = $db:select" below my entry tag, my issue is occuring in the mixed content xml where I can't seem to eliminate duplicates...hope this helps. |
Is that the whole of the MAP you have defined in the mapping node?
Again, posting the data you are starting with and the result you are trying to get is not much help.
Please post the statements you are using in the map. All of them, please.
And, again, you do not have mixed content in your XML.
Mixed content is something like
Code: |
<tag1>value of tag1<tag2>value of tag2</tag2></tag1> |
. |
|
Back to top |
|
 |
Fayaz |
Posted: Wed Aug 24, 2011 9:09 am Post subject: |
|
|
Novice
Joined: 21 Jul 2011 Posts: 18
|
Check below for the map I have currently, what I can't figure out is what IF statement would I need here to eliminate the repeating elements for col2 & col3....I have tried occurences, exists etc.. to no avail....any help will be greatly appreciated..
Code: |
Target Source
ContentMaster
Entry
$db:select $db:select:db.dbo.Table_col1 = 1
for $db:select
col1 $db:select:db.dbo.Table_col1
IF
col2 $db:select:db.dbo.Table_col2
col3 $db:select:db.dbo.Table_col3 |
If I do this I can atleast get first part of the resultset which is as below:
Code: |
<ContentMaster>
<Entry>
<Col1>1</Col1>
<Col3 Col2="English">Title - en</Col3>
<Col3 Col2="French">Title - fr</Col3>
<Col3 Col2="German">Title - de</Col3>
</Entry>
</ContentMaster> |
|
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 24, 2011 9:15 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
Fayaz |
Posted: Wed Aug 24, 2011 9:39 am Post subject: |
|
|
Novice
Joined: 21 Jul 2011 Posts: 18
|
Ok tried it as below:
Code: |
Target Source
ContentMaster
Entry
$db:select $db:select:db.dbo.Table_col1 = 1
for $db:select
col1 $db:select:db.dbo.Table_col1
for $db:select:db.dbo.Table_col2
IF msgmap:occurrence($db:select:db.dbo.Table_col2) = 1
col2 $db:select:db.dbo.Table_col2
col3 $db:select:db.dbo.Table_col3 |
Now this just returns the below output
Code: |
<ContentMaster>
<Entry>
<Col1>1</Col1>
<Col3 Col2="English">Title - en</Col3>
</Entry>
</ContentMaster> |
instead of below
Code: |
<ContentMaster>
<Entry>
<Col1>1</Col1>
<Col3 Col2="English">Title - en</Col3>
<Col3 Col2="French">Title - fr</Col3>
<Col3 Col2="German">Title - de</Col3>
</Entry>
</ContentMaster> |
|
|
Back to top |
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|