When writing XML Files with Stambia, the default behavior for null values is to not include the element/attribute in the file.
But we might need to include null or empty values in the file and there are several solutions to do it.
The difference between empty and null values is:
- Empty value will return "" (an empty string for example if the element is a string)
- Null value will return the real null value
Including empty values
Empty values can be set in the mapping expression with two single quotes.
Note :
As oracle consider empty values as null (cf : https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements005.htm) this solution will not work on oracle databases.
Example :
Result :
Including null values
To include the real 'null' value into an element :
- Type
null
in the mapping expression - Set the
Nil Behavior
parameter of the template toTrueIfNotDefined
.
Note :
This will only work for elements, not attributes.
Example :
Result :
xsi:nil
represents the null value in XML.
For further information about nil behavior you can look at :
http://stackoverflow.com/questions/774192/what-is-the-correct-way-to-represent-null-xml-elements
http://www.w3.org/TR/xmlschema-1/#xsi_nil