| ILOG JRules User Guide > Integrating Application Data > Tasks > Using the XML Binding API > Managing Unknown Operators on Attributes and Elements |
Managing Unknown Operators on Attributes and Elements |
PREVIOUS NEXT |
Unlike Java object attributes or elements, where isknown returns true even if the attribute or element is equal to null, XML objects can have optional attributes or elements that are unknown.
An optional XML attribute or element is unknown if, in the XML document:
In the ILOG Rule Language (IRL), you can check if there is a value for optional attributes using the isknown and isunknown operators and, if there is, retrieve it.
The operators isknown and isunknown do not exist in the Business Action Language (BAL). To apply these operators, you need to create a method in the BOM, then use BOM to XOM mapping. The following example shows an example for a lastName attribute.
To apply the isknown/isunknown operators:
isKnownLastName method, you can then protect access to the lastName attribute in the business rules. For example, you can write the following rule condition:
unknown: for non-primitive types, such as String, you need only set the attribute to null. In IRL code you can do this as:
If the type of the optional attribute is a primitive type, the XML binding generates the XOM method setUnknown<AttributeName>. You can therefore unset an age attribute of type int using:
?customer.setUnknownAge();
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |