Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


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

Read-Only Read-Only Topic
Go
Search
Notify
Tools
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, 2010Report 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, 2007Report 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)


--
WebFOCUS 8.2.03 on Linux
 
Posts: 8 | Location: Canada | Registered: March 23, 2010Report 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, 2010Report 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’))
 
Report 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.


--
WebFOCUS 8.2.03 on Linux
 
Posts: 8 | Location: Canada | Registered: March 23, 2010Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

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-2020 Information Builders