Handling Null, Empty, and Missing Values - Documentation for Ar System 22.1

This topic discusses the rules for handling null, empty, and missing values.

Elements and attributes mapped to fields

The rules for mapping XML elements and attributes to fields can be divided into four groups.

  • Incoming XML elements
  • Incoming XML attributes
  • Outgoing XML elements
  • Outgoing XML attributes

AR System  has two sources for incoming XML:

  • The request for published web service published through  AR System
  • A response from an external web service that  AR System is consuming

Similarly, there are two sources for outgoing XML:

  • The response from a web service published through  AR System
  • The request to an external web service that  AR System is consuming

In these tables it is assumed that "name" is an XML element or attribute that is missing, empty, or nulled, and is mapped to a  AR System field called Name. The column headers are the design-time properties. For example, "name" is defined with minOccurs=0 and nillable=false. The row headers are run-time representations. For example, in the incoming XML packet "name" appears as <name></name>. The table specifies how  AR System sets the XML element or attribute to or from the  AR System field.

Tip

To render a null field, create an empty element with xsi:nil=true as an attribute. This is preferable to omitting the element in the request document, or creating an empty element with the nillable attribute set to false.

Incoming XML elements mapped to fields

minOccurs=0 and nillable=false

minOccurs=0 and nillable=true

minOccurs=1 and nillable=false

minOccurs=1 and nillable=true

Missing <name>

Name is not modified, or it is set to AR default. (1)

Name is not modified, or it is set to AR default. (1)

Invalid XML (2)

Invalid XM. (2)

<name></name> OR <name/>

Name=$NULL$ or xsd default (3)

Name=$NULL$ or xsd default (3)

Name=$NULL$ or xsd default (3)

Name=$NULL$ or xsd default (3)

<name xsi:nil="true></name> OR <name xsi:nil="true"/>

Invalid XML. (5)

Name=$NULL$ (4)

Invalid XML (5)

Name=$NULL$ (4)

  1. When an XML element is missing,  AR System treats it the same way as a missing field. Therefore, in a create operation, the field to which the XML element is mapped assumes the  AR System default value (or NULL if there is no default). In a set operation and in consumption, the field remains unchanged.
  2. When an XML element is missing, in spite of minOccurs=1, it is invalid XML. The client should not send such an XML packet, but if it does,  AR System displays an error message.
  3. When the XML element has empty content,  AR System first tries to use the xsd default if it exists. (There are two different defaults—the  AR System default value and the xsd default value. For empty contents,  AR System always uses the default xsd value.) Otherwise, it sets the field to NULL.
  4. When the XML element has xsi:nil=true,  AR System sets the field to NULL and disregards the defaults.
  5. When the XML element has xsi:nil=true but is not defined with nillable=true, it is invalid XML. Clients should not send such an XML packet. Also,  AR System sets this field to NULL, disregarding the defaults.
  6. To an XML element to be returned in a Web Service output, AR Server adds the xsi:nil attribute only if the XML element has a NULL value, is defined to allow NULL values (nillable=true), and there is no default value assigned to it.
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest