isunknown

The isunknown keyword tests whether a class attribute has an initialized value.

Purpose

This keyword is used in the condition part or in the action part of a rule or in a function to test whether the attribute has a value.

Context

Any expression

Syntax

[?var:] className (?attribute isunknown);

Description

In the case of XML binding, an attribute has no value in the following cases:

  • When the value is not given in the XML file, or

  • When the value is given in the XML file and set to xsi:nil.

In the case of Java™ classes, the test always returns false because a Java attribute of a Java class is never considered as not initialized.

Example

rule TestUnknownValue {
    when {
      ?u: User(address isunknown);
    } 
    then {
       askForAddress(?u);
    }
  };