Page last modified 14:10, 28 Dec 2015 by Antero

3. OCL statement

    Table of contents

    Version as of 18:26, 23 Jan 2022

    to this version.

    Return to Version archive.

    View current version


    OCL rules are used to execute constraints against XML file. These rules always return a boolean value, either true or false.


    OCL rules, together with context, form the core part of the business rule. It is crucial to first understand the concept of context. In short, context is set to be complex or simpleType defined in the relevant schema, and OCL-rule is ran whenver the type defined in the context is found within the XML-file.

    Restriction defined in the OCL-statement returns a boolean value. Whenever false is returned, XMLdation service will return an error message to a pre-defined location within the XML-file (defined by OCL-query), with a pre-defined error message. Whenever true is returned, the restriction passes and XML file is considered valid against that rule.

    OCL-queries and error messages are defined by the creator of the OCL-rule.


    Rule is written so that it matches the business rule it is depicting. For example, when a business rule is:

    Debtor name must be "The initiator"

    OCL-restriction is written in same form, so that valid case is depicted in the rule

    Context: HeaderType1
    OCL: self.Debtor.Name = "The initiator"
    Description: Rule defines a specific value for Debtor/Name.


    When an erreneous file against that rule is inserted to validation pipe, an error will be returned whenever Debtor Name is not the one defined in the statement.

    Multiple rules may be present in validation pipe, together they form a ruleset. Multiple rulesets may be present as well. The names of these rulesets are returned in the validation results page.


    Let's have a more thorough look at the business rule depicted above, "Debtor name must be "The initiator".