Subject:Map field if source is not null Author:Romie Behunin Date:18 Jun 2009 06:07 PM
I'm pretty new to this tool so please forgive me for my ignorance. I'm using the XSLT mapper to map a field to a destination field IF the value of the field is not null. Otherwise I want to insert the current date and time in the destination field. I understand how to obtain the current date and time in my destination field by setting the text value but I'm having difficulty with the IF function as I guess I don't completely understand how to work it. Any direction is greatly appreciated! Thanks~!!
Subject:Map field if source is not null Author:Alberto Massari Date:19 Jun 2009 10:45 AM
the IF function in XSLT doesn't have a "ELSE" statement, so it can only be used to generate an output if the source is not empty. If you want do perform a different operation when the condition is false you need to use the CHOOSE instruction.
- right click on the canvas and pick XSLT Instructions -> choose;
- drag a link from the element you want to test to the left port of the "choose" block
- drag a link from the top right port of th e"choose" block to the desired target element (this will be the path when the condition is true)
- drag a link from the bottom right (square) port of the "choose" port to the desired target element (this will be the "otherwise" condition, when all the tests of the "choose" fail)
- now drag links from the source tree to the two different target elements in order to fill them with values.
If the target element created by the "choose" block is the same, you will have to duplicate it by right clicking on it and choosing Duplicate Node
Subject:Map field if source is not null Author:Romie Behunin Date:19 Jun 2009 11:26 AM
Thanks for the assistance. I've read a number of your posts and your experience is very helpful! After doing some trial and error work and testing on this I realized that the value would never be null... but rather possibly = ''. I gave up using the GUI to try this (because of my inexperience with it) and inserted my own code like this:
It seems to be working the way I intended so far. I was suprised to see how the GUI mapped this out but it gave me a better understanding what the flow port is for. I'm going to practice with the choose function as well per your suggestions.