ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker (ACE) SupportHandling nil='true' while mapping transformation ?

Post new topicReply to topic
Handling nil='true' while mapping transformation ? View previous topic :: View next topic
Author Message
shashivarungupta
PostPosted: Sun Mar 08, 2015 3:19 pm Post subject: Handling nil='true' while mapping transformation ? Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

Hi,

Can WMB v8.0.0.4, Mapping Node translate an input message element into an output message element, when input XML element is present but has no value (i.e. <tag></tag> or <tag xsi:nil:”true”/>. (Assuming, Output Message Schema Model allows to set an element with no value) ?

Can WMB v8.0.0.4, Mapping Node translate an output message element with nil=’true’ when input element is not present in the message. (Assuming, Output Message Schema Model allows to set an element with no value) ?

I have found few fixes by IBM (listed below), done on v8.0.0.2 and v8.0.0.3 to deal with NULL and NIL elements, during Mapping. These changes should be applied to v8.0.0.4 logically by being backward compatible changes.

Code:

In version 8.0.0.3
IC87673
Xmlnsc parser writes invalid xsi namespace for xsi:nil attributes
IC92508
Xsi:nil elements not passed to esql from mapping node as null
IC93916
Treat empty string results as nil for non-string targets

In version 8.0.0.2
IC87673
Xmlnsc parser writes invalid xsi namespace for xsi:nil attributes
IC89507
Mapping node drops xsi:nil attributes


The question is, are the above fixes suffice to say that the aforementioned concerns can be easly dealt in v8.0.0.4 broker while mapping using mapping node?


_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
shashivarungupta
PostPosted: Sun Mar 08, 2015 6:13 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

In other words...

How can I check the attribute xsi:nil="true" is set (to true or false) in the message for that input element, during mapping transformation, to the output element?


_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
shanson
PostPosted: Mon Mar 09, 2015 1:50 am Post subject: Reply with quote

Partisan

Joined: 17 Oct 2003
Posts: 344
Location: IBM Hursley

I would start at this topic in the infocenter: br28815_
Back to top
View user's profile Send private message
shashivarungupta
PostPosted: Mon Mar 09, 2015 12:26 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

shanson wrote:
I would start at this topic in the infocenter: br28815_


If you mean the following URL, then I don't get anything at InfoCenter.

http://www-01.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/br28815_.htm?lang=en

KC0024E: The topic was not found. The link might not be correct, or the topic does not exist. Check that the URL is correct and try again.
_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
shashivarungupta
PostPosted: Mon Mar 09, 2015 12:31 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

Quote:
How can I check the attribute xsi:nil="true" is set (to true or false)


I've found and I believe as per IBM InfoCenter.. we can do the above by using following function (while mapping transformation).

fn:nilled tests whether an XML element has the xsi:nil attribute set.


Whereas what if I want to assign xsi:nil="true" child attribute to an output element when input element is empty <e1></e1> or </e1>, using Mapping? Can this be done, How?


_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
martinb
PostPosted: Tue Mar 10, 2015 2:46 am Post subject: Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

Hi

The info center topic that covers these aspects is in the IIB v9 / v10 topic
Handling nulls in message maps

I believe what you want to detect is an input element being present but having no value and then create an output element as nilled.

If the input can be valid with no value, lets assume it's a simple xsd:string type, then you can have a mapping like

if ( $<input> = '' )
Create $<output> as nilled
else
$<input> Move $<output>

Here I'm suggesting using an explicit Create transform and setting the "create nilled" option, which will be offered if the target element is defined as nillable in the schema model.

Note if the target element is mandatory, minOccurs=1, and nillable, then the mapping node will create the target as nilled if a input mapping if from an input element that is missing, or has xsi:nill attribute set.

However since you want to turn the "no value" into "nilled" you have to use the explicit if and create as nilled solution.
Back to top
View user's profile Send private message
shashivarungupta
PostPosted: Tue Mar 10, 2015 2:32 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

martinb wrote:

The info center topic that covers these aspects is in the IIB v9 / v10 topic
Handling nulls in message maps


Though I've been facing issues on v8.0.0.4 (not on IIB9). But thanks for sharing this information.

martinb wrote:

I believe what you want to detect is an input element being present but having no value and then create an output element as nilled.

Yes.

martinb wrote:

If the input can be valid with no value, lets assume it's a simple xsd:string type, then you can have a mapping like

if ( $<input> = '' )
Create $<output> as nilled
else
$<input> Move $<output>


Yes. I've been trying do this. But this doesn't seem to work as IBM documents it here.
Sometimes the mapper is dropping the output elements or its generating the element as empty (where the schema has output elements as nillable).

martinb wrote:
Here I'm suggesting using an explicit Create transform and setting the "create nilled" option, which will be offered if the target element is defined as nillable in the schema model.
Note if the target element is mandatory, minOccurs=1, and nillable, then the mapping node will create the target as nilled if a input mapping if from an input element that is missing, or has xsi:nill attribute set.

However since you want to turn the "no value" into "nilled" you have to use the explicit if and create as nilled solution.


How do you select "Create" transform when the element is not of array type Or its cardinality is [0..1] or [1..1] but not [0..*] or [1..*] ?
By the way, I've tried schema elements (input and output both) setting with minOccurs as 0 and 1 both.
* Incase of minOccurs=0 and when input element is not blank (say <e1>HELLO</e1>) , then using simple MOVE transform to output element , it somehow dropping the output element itself.
* Incase of minOccurs=1 and when input element is not blank (say <e1>HELLO</e1>) , then using simple MOVE transform to output element , it somehow generating the output element with no value.
* Incase of minOccurs=1 and when input element is blank (say <e1 xsi:nil="true"></e1>) , then using simple MOVE transform to output element , it somehow generating the output element with no value (whereas it should have generated the output element with xsi:nil="true" as per IBM doc given above).

In these cases, the mapping behaviour is not as per the IBM document, sadly.


_________________
*Life will beat you down, you need to decide to fight back or leave it.


Last edited by shashivarungupta on Thu Mar 19, 2015 12:36 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
shashivarungupta
PostPosted: Sun Mar 15, 2015 2:10 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

Quote:
Yes. I've been trying do this. But this doesn't seem to work as IBM documents it here.
Sometimes the mapper is dropping the output elements or its generating the element as empty (where the schema has output elements as nillable).


... To fix it, need to take care of domain (xmlnsc or soap) while message transformation. If input message is soap and mapping needs to be applied on them, apply soapExtract before mapping (with xmlnsc). Else prefer the soap domain while mapping.


_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
martinb
PostPosted: Mon Mar 16, 2015 10:51 am Post subject: Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

Hi

Sounds like you are sorted now?

Indeed you highlight good point to remember

- When Mapping node is directly following a SOAPInput node and
- There is no SOAPExtract node
- The Mapping node is not in an Operation subflow of an Integration Service
then Map must be created using IBM defined SOAP Domain message, and making a cast of SOAP.Body to relevant operation element
- Otherwise when there is an extract, the map is created directly using schema of operation


With regards the v8 Info Centre topic ac70560 "Handling null values" there is currently an error in the GDM section, it incorrectly describes "fn:empty". It needs to be corrected like:

fn:empty. Tests whether a set of elements is empty, that is it returns true or a a missing element that is not present in the logical tree

To test a xsd:string typed element having a value of the empty string use if ( $<input> = '' )
Back to top
View user's profile Send private message
shashivarungupta
PostPosted: Mon Mar 16, 2015 5:23 pm Post subject: Reply with quote

Grand Master

Joined: 24 Feb 2009
Posts: 1343
Location: Floating in space on a round rock.

martinb wrote:

Sounds like you are sorted now?


Yup, Almost !!
(apart from some other minor clarification when broker mapping generates child attribute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" including xsi:nil="true" in the response message element.)

martinb wrote:

Indeed you highlight good point to remember

- When Mapping node is directly following a SOAPInput node and
- There is no SOAPExtract node
- The Mapping node is not in an Operation subflow of an Integration Service
then Map must be created using IBM defined SOAP Domain message, and making a cast of SOAP.Body to relevant operation element
- Otherwise when there is an extract, the map is created directly using schema of operation


With regards the v8 Info Centre topic ac70560 "Handling null values" there is currently an error in the GDM section, it incorrectly describes "fn:empty". It needs to be corrected like:

fn:empty. Tests whether a set of elements is empty, that is it returns true or a a missing element that is not present in the logical tree

To test a xsd:string typed element having a value of the empty string use if ( $<input> = '' )


You reminded me to check few more points related to empty elements of different data types, while mapping transformation for xsi:nil attribute. Thanks.
_________________
*Life will beat you down, you need to decide to fight back or leave it.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker (ACE) SupportHandling nil='true' while mapping transformation ?
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.