Author |
Message
|
shashivarungupta |
Posted: Sun Mar 08, 2015 3:19 pm Post subject: Handling nil='true' while mapping transformation ? |
|
|
 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 |
|
 |
shashivarungupta |
Posted: Sun Mar 08, 2015 6:13 pm Post subject: |
|
|
 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 |
|
 |
shanson |
Posted: Mon Mar 09, 2015 1:50 am Post subject: |
|
|
 Partisan
Joined: 17 Oct 2003 Posts: 344 Location: IBM Hursley
|
I would start at this topic in the infocenter: br28815_ |
|
Back to top |
|
 |
shashivarungupta |
Posted: Mon Mar 09, 2015 12:26 pm Post subject: |
|
|
 Grand Master
Joined: 24 Feb 2009 Posts: 1343 Location: Floating in space on a round rock.
|
|
Back to top |
|
 |
shashivarungupta |
Posted: Mon Mar 09, 2015 12:31 pm Post subject: |
|
|
 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 |
|
 |
martinb |
Posted: Tue Mar 10, 2015 2:46 am Post subject: |
|
|
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 |
|
 |
shashivarungupta |
Posted: Tue Mar 10, 2015 2:32 pm Post subject: |
|
|
 Grand Master
Joined: 24 Feb 2009 Posts: 1343 Location: Floating in space on a round rock.
|
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 |
|
 |
shashivarungupta |
Posted: Sun Mar 15, 2015 2:10 pm Post subject: |
|
|
 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 |
|
 |
martinb |
Posted: Mon Mar 16, 2015 10:51 am Post subject: |
|
|
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 |
|
 |
shashivarungupta |
Posted: Mon Mar 16, 2015 5:23 pm Post subject: |
|
|
 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 |
|
 |
|