BizTalk: Mapping, Logical functoids, and Boolean values

BizTalk: Mapping, Logical functoids, and Boolean values

 

Several times I've got "non intuitive" result by using boolean values in maps.

For example, I've tried to get values "true/false" or something else from the logical functoids for filling up the node in a Destination schema, but didn't get anything.

 

Here is my discovering using boolean value in the maps.

 

There are different flavors this problem:

·         Where we can use boolean values?

·         Where we can get boolean values?

·         How we can fill in the nodes with boolean type?

·         How we can transform boolean values?

 

Let’s start.

 

Script functoid

In the xml document all values are the strings.

It should be (and it is!) non intuitive to transform them to/from the .NET bool values. It can be transformed by using Script functoids. (Pict.1)

 

 

 

I've tested two variants of "inline C#" scripts:

I used the negation operator (“!”) to be sure I’m having a real transformation.

 

string BoolToString (bool paramBool )

{

            return (!paramBool).ToString() ;

}

 

And

 

bool BoolToBool (bool paramBool )

{

            return (!paramBool);

}

 

Results:

1.       When I changed the link from FieldBoolean node to Functoid to the link from FieldString to Functoid the results were the same.

2.       When I changed the input value as “True” / ”true” / “TRUE” / “tRuE” the results were the same.

3.       First script returned values “False” / “True” when I passed into it “true” / “false”.
Second script returned values “false” / “true” when I passed into it “true” / “false”.

4.       When the input value were “1” / “0” I’ve got the errors.

 

Conclusion:

1.       Script functoid ignores the types of nodes. It always inputs/outputs the string values. Before/after passing them to/from the script it transforms them to the .NET type.

2.       Script functoid ignores the cases of the input values when transform them on the boundary of the script to the bool type.

3.       Script returns the bool values (transformed on the boundary of the script to the string type) as defined for Microsoft .NET Framework Class Library (see the References below). That’s mean bool values are “true and “false”, bool values transformed inside script to the string values are “True” and “False”.

4.       Script functoid implement only “Canonical representation” of the “boolean” type of XML schema not a “Lexical representation” (see the References below). That’s mean the values “1” and “0” should not be used as boolean values in the Script functoid input.

Logical functoids

It’s confusing from the start.

When you see to the Help property of a Logical functoid you can see: “Returns TRUE if the first parameter is equal to the second parameter.”

But into the Configure Functoid Inputs window

“Functoid description:

Use the Equal functoid to return the value “true” if the first input parameter is equal to the second input parameter. This functoid requires two input parameters.”

 

We can see the different cases in the values.

Is that something mean for us?

 

I use several maps for testing the logical functoids. (If the Equal functoid is picted with one input link the second input parameter is usualy “true”.) :

 

(Pict.2)

Here I tried to get the output value from the logical functoid to the destination node.

 

(Pict.3)

 Here is the standard method of using the logical functoid.

 

(Pict.4)

Here I tried to understand which values return the logical functoid.

 

 

Let’s start testing.

Results:

1.       In first case the Logical functoid output didn’t create the destination values.

2.       When I’ve tried to use “True” or “TRUE” or something else as an argument in place of the logical argument (for example, as a first argument of Value mapping functoid) it didn’t match. Only “true” is working fine.

3.       In the third test the second logical functoid matched only values “true”/”false” not “True”/”False” nor “TRUE”/”FALSE”.

Conclusion:

1.       We can not get the output value from the logical functoid to the destination node. Seems it could be used only as an input value for other functoids.

2.       The logical functoids understand only the low case values, “true” and “false”.

3.       The only place where I can use the “literal” logical value generated by the logical functoid is the input of another logical functoid, i.e. the functoid chain. And the logical functoids can only return the low case values, “true” and “false”.

4.       Help property of a Logical functoid has an error. The logical functoids can return not “TRUE” but “true”.

Other functoids

Some non-logical functoids can use the boolean values returned by the logical functoids. They are a Value mapping functoid and Value mapping (Flattening) functoid. Not sure about other functoids.

 

 

(Pict.5)

 

IMHO Behavior of the Boolean values and the Logical functoids in the maps are not intuitive.

 

 

References:

XML Schema Part 2: Datatypes Second Edition

W3C Recommendation 28 October 2004:

 

"...

3.2.2 boolean

[Definition:] boolean has the ·value space· required to support the mathematical concept of binary-valued logic: {true, false}.

 

3.2.2.1 Lexical representation

An instance of a datatype that is defined as ·boolean· can have the following legal literals {true, false, 1, 0}.

 

3.2.2.2 Canonical representation

The canonical representation for boolean is the set of literals {true, false}.

..."

 

 

Microsoft .NET Framework Class Library:

 

"…

Boolean.TrueString Field 

 

Represents the Boolean value true as a string. This field is read-only.

 

public static readonly string TrueString;

 

Remarks

This field is equal to the string "True".

…"

 

 

SQL Server doesn't save the Boolean type.

It works with it in Logical operator, that’s all:

SQL Server Books Online:

 

"...

Logical Operators

Logical operators test for the truth of some condition. Logical operators, like comparison operators, return a Boolean data type with a value of TRUE or FALSE.

..."

 

Arguments

boolean_expression

 

"...

Is any valid Microsoft® SQL Server™ expression that returns a Boolean value: TRUE, FALSE, or UNKNOWN.

 

Result Types

Boolean

..."

 

Print | posted on Friday, January 13, 2006 5:45 PM

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification: