Welcome Guest! Log in
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.


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 :

empty

Result :

emptyResult

 

Including null values

To include the real 'null' value into an element :

  1. Type null in the mapping expression
  2. Set the Nil Behavior parameter of the template to TrueIfNotDefined.

Note :

This will only work for elements, not attributes.

Example :

null

Result :

nullResult

 

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

 

You have no rights to post comments

Articles

Suggest a new Article!