XMLNillable

Define an XML element to be explicitly null and serialized with the xsi:nil="true" value. It specifies how a NULL value is set on an XML node when the BDL variable is NULL but not optional.
Note: The XMLNillable attribute cannot be set on a TYPE definition. If you need to set nillable in a record defined from a database schema with LIKE clause, the XMLElementNillable attribute supports an implementation that sets all elements in the record to XMLNillable.
The XMLNillable attribute is used on its own, or in combination with the XMLOptional attribute to specify conditions for the XML node depending on how you want the BDL variable value to be serialized:
  • XML node optional (when null)
  • XML node nillable (when null)
  • Option of either XML node optional or nillable, with preference for nillable.
Examples are shown for each use.

Example optional

The variable "val2" is optional when null
DEFINE var RECORD
     val1 STRING,
     val2 INTEGER ATTRIBUTES(XMLOptional),
     val3 FLOAT
END RECORD
The resulting XML document is:
<var>
  <val1>Hello</val1>
  <val3>3.1415</val3>
</var>

Example nillable

The variable "val2" is nillable when BDL variable is NULL but not optional.
DEFINE var RECORD
     val1 STRING,
     val2 INTEGER ATTRIBUTES(XMLNillable),
     val3 FLOAT
END RECORD
In the resulting XML document "val2" is serialized with the xsi:nil="true" value:
<var>
  <val1>Hello</val1>
  <val2 xsi:nil="true"/>
  <val3>3.1415</val3>
</var>

Example optional or nillable

The variable "val2" is either optional or nillable if BDL variable is NULL.
DEFINE var RECORD
     val1 STRING,
     val2 INTEGER ATTRIBUTES(XMLNillable,XMLOptional),
     val3 FLOAT
END RECORD
In the resulting XML document "val2" is missing as it is defined by XMLOptional (the default).
<var>
  <val1>Hello</val1>
  <val3>3.1415</val3>
</var>
Or the resulting XML document can show "val2" nillable:
<var>
  <val1>Hello</val1>
  <val2 xsi:nil="true"/>
  <val3>3.1415</val3>
</var>
Note: If both XMLOptional and XMLNillable are set and the BDL variable is NULL, the serialization process from BDL to XML uses XMLOptional by default. If you prefer to serialize as xsi:nil="true", you must specify the "preferred" value as a parameter of XMLNillable.
DEFINE var RECORD
     val1 STRING,
     val2 INTEGER ATTRIBUTES(XMLNillable="preferred",XMLOptional),
     val3 FLOAT
END RECORD

XML transformation into BDL

When getting an XML transformation into BDL, the Web Service engine will not raise an error and the variable is set correctly whether the variable tag is missing or has xsi:nil="true" set. In either case, the BDL variable is set as NULL.