Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  iWay Software Product Forum on Focal Point    Passing null to custom function from within a Transform
Go
New
Search
Notify
Tools
Reply
  
Passing null to custom function from within a Transform
 Login/Join
 
Member
posted
Hello,

I am calling a custom function from within an XML to XML Transform. The function accepts several parameters which are populated from the transform input document.

Whenever I try to pass a null value as one of the parameters using either @NULL or by mapping an empty element (eg ) then it seems the function actually receives an empty string and not a null.

Does anyone have a solution for this?


(iWay 6.0.1 on Intel/Linux)


iWay 6.0.1 on Intel/Linux
 
Posts: 2 | Registered: March 03, 2010Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi Rob,
You need to use the code tags if you're putting xml / html into your post.

Cheers,
Ade


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Member
posted Hide Post
Hi,

You can try to enable the debug traces and see what is actually being retreived from your document and what is being sent to your custom function.

How does the custom function reporting that it is receiving an empty string?

quote:
Originally posted by RobT:
Hello,

I am calling a custom function from within an XML to XML Transform. The function accepts several parameters which are populated from the transform input document.

Whenever I try to pass a null value as one of the parameters using either @NULL or by mapping an empty element (eg ) then it seems the function actually receives an empty string and not a null.

Does anyone have a solution for this?


(iWay 6.0.1 on Intel/Linux)


--
iSM 6 on AIX,
iSM 6 on Windows 2008 Server
WebFOCUS 8.0.03 on AIX
 
Posts: 8 | Location: Canada | Registered: March 23, 2010Reply With QuoteReport This Post
Member
posted Hide Post
Thanks for your responses so far.

The empty XML element I was trying to display in my original post was
<movementSubType/>


A section of the debug logs are shown here.

09:59:54.647 DEBUG W.O_STATUS_CON_MQ.7 TranslateMovementCode : returning from execute method , took time : 1
09:59:54.647 DEBUG W.O_STATUS_CON_MQ.7 movementSubType is EMPTY String :::
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 movementSubType is :::
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 movementType is ::: RO
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 Argument length is ::: 2
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 TranslateMovementCode : inside execute method


As you can see, our custom function's logging tells us it received an Empty String (this logging was specifically added to the function to troubleshoot this particular problem). Also, the final results returned by the function indicate it received an empty string and not a null.


iWay 6.0.1 on Intel/Linux
 
Posts: 2 | Registered: March 03, 2010Reply With QuoteReport This Post
<nklamen>
posted
The pre-defined @NULL function represents the empty constant parameter, and it is not applicable for the use cases that you described. But if you’d like to pass NULL parameter into Transformer custom function call, it needs to be represented by a null context (context is Transform input document path, similar to XPATH) which would be the context that does not exist in the input. Here is an example on how to define the null context parameter to be passed into your custom function. It can be any unique context that is not expected in the data. It is recommended to be used as global constant. You can define it in your custom function and pass it as constant mapping, for example:

(1) In the function code:
static final String NULL_CONTEXT = “NULL/NULL”;
(2) In the transform project:
Define null context as global variable, or global constant.
- Open transform properties and create a new global constant with name NULL_CONTEXT and map it to a constant with a value same as one defined in the function: NULL/NULL
When designing mappings between input and output structures, use NULL_CONTEXT instead of @NULL function.
@CUSTOM_FUNC (‘abc’, @GETCONSTANT(‘NULL_CONTEXT’))
 
Reply With QuoteReport This Post
Member
posted Hide Post
Hi again,

I might be off here because you mentionned trying to pass @NULL before, but you know that there is no "NULL" in XML since everything is a string... So, I understand there are 2 ways of creating a NULL value. For example:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <FirstNULL xsi:nil="true">
</root>


/root/FirstNULL 
if it is defined with the nillable attribute set to true.
/root/SecondNULL
if the element is defined but not showing.

The other thing you could try is to modify your code to handle NULL or emptry strings as null values...

quote:
Originally posted by RobT:
Thanks for your responses so far.

The empty XML element I was trying to display in my original post was
<movementSubType/>


A section of the debug logs are shown here.

09:59:54.647 DEBUG W.O_STATUS_CON_MQ.7 TranslateMovementCode : returning from execute method , took time : 1
09:59:54.647 DEBUG W.O_STATUS_CON_MQ.7 movementSubType is EMPTY String :::
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 movementSubType is :::
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 movementType is ::: RO
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 Argument length is ::: 2
09:59:54.646 DEBUG W.O_STATUS_CON_MQ.7 TranslateMovementCode : inside execute method


As you can see, our custom function's logging tells us it received an Empty String (this logging was specifically added to the function to troubleshoot this particular problem). Also, the final results returned by the function indicate it received an empty string and not a null.


--
iSM 6 on AIX,
iSM 6 on Windows 2008 Server
WebFOCUS 8.0.03 on AIX
 
Posts: 8 | Location: Canada | Registered: March 23, 2010Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  iWay Software Product Forum on Focal Point    Passing null to custom function from within a Transform

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.