posts - 3, comments - 2, trackbacks - 3

My Links

News



Archives

Logical Existence does not return False?!

I have recently come across an issue that when mapping from one schema to another where the inbound message has a missing record, the outbound message does not create a record of the non-existed input record if mapped to it as it does not exist.

 

Say for example, you have a record (either a single or multiple typed) called <Details> and sometimes the inbound message does not have it for any reason, let's say no data were available but the message was still sent anyhow, may be because it has some other types of records. Yet, the client on the receive side does not like that and wanted the structure of the message to remain the same no matter what...

 

Sample of a Complete Inbound Message structure:

 

 

<ns0:Root xmlns:ns0="http://MissingRecordsSample.InboundSchema_XML">

 <NCode>2311</NCode>

  <Details>

    <Name>Kamal</Name>

   <Address>Somewhere</Address>

    <PostCode>TS3 3TS</PostCode>

  </Details>

</ns0:Root>

 

 

Sample of a missing record in the Inbound Message:

 

 

<ns0:Root xmlns:ns0="http://MissingRecordsSample.InboundSchema_XML">

 <NCode>2312</NCode>

</ns0:Root>

 

 

When trying the Logical Existence Functoid to check the existence of the record and map it accordingly, the Functoid only returned True when the record exists but does not return False when the record does not exist! (Ok, don’t ask me why, apparently this is how it is suppose to behave– Check the MSDN)

 

So, the problem I am trying to resolve here is to not lose the structure of the outbound message whether the inbound message has missing records or not.

 

Anyhow, fiddling around with the Logical Existence Functoid, trying a combination of other Functoids, playing with the in/out schemas properties to see if I could set the max occurs or have a default values etc etc. In short, nothing works!

 

Eventually, I found two ways of doing this, nothing funky but both worked perefectly. One of them involve writing a piece of XSLT code (Wrote some of it, worked but returning the first record when the inbound record existed and did not return the rest as the record was mapped from is a multiple one. Anyhow, I did not proceed any further as it was getting more complicated and not very maintainable!)

 

The second solution which I favour involves creating a default empty record in the outbound message regardless of whether the inbound message has complete records or not. Although this was a specific requirement to leave the empty records, the redundant empty records could be eliminated by creating a second map to do that.

 

The solution:

 

Creation of the empty record:

 

Identify a single field or a record that you know it will always exist in the inbound message, in my example, the NCode was the one.

 

Drag a Looping Functoid and create a link between the NCode field (inbound) and the <Details> record (outbound). This will always create the <Details> record but would not create the fields inside it and that’s why we need to add a Logical Existence & Value Mapping Functoids to return empty string value when the Logical Existence is True which we know it will always be true as we are linking it to the NCode.

 

Link the Logical Existence Functoid to the Value Mapping and in the Input Parameters property, create an empty string value as the second parameter. Now, link the Value mapping functoid to every field inside the record (outbound) to create a full set of empty fields.

 

Mapping of the completed records:

 

To map the fields and records that have real values, we need to do the same but this time the value mapped to the Value Mapping Functoid is not an empty string but a link from the inbound message returning its value if the logical existence is True (it may not return anything if the inbound record is missing).

Photobucket - Video and Image Hosting

Result:

 

If the inbound message has completed records then all completed records will be mapped to the outbound message plus an empty record. (Note: if you need to eliminate the empty record then you would need to do this in a second map, if you have a better way of doing it then please let me know.)

 

If no records are in the inbound message then a single empty record will be created. Which resolved my problem.

 

 

I hope that was helpful. I have created a sample project illustrating this, let me know if you want me to email it to you.

 

Print | posted on Tuesday, November 14, 2006 4:25 PM |

Feedback

Gravatar

# re: Logical Existence does not return False?!

Can you send me a copy of the xslt code that you were used to get this to work? britttd at hotmail dot com

THANKS. I'm having trouble with this portion and am trying to get it to work this way.
12/11/2006 10:04 PM | Tim
Gravatar

# re: Logical Existence does not return False?!

Has been sent you. Hope you find it useful..
1/23/2007 8:27 AM | Kamal Ali
Gravatar

# re: Logical Existence does not return False?!

You can get this functionality to work. Just keep the original functoid structure (Logical Existence and the Not Functoids), then add a Looping functoid. Make the source of the Looping functoid a node that you KNOW will be there, and the output of the Looping Functoid the node you want to always create in the destination. Now it will create the node in the destination with the default value when the source node does not exist, and the mapped value when it does.

Good luck.

Dan
1/10/2008 5:03 AM | Daniel
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: