Page last modified 12:26, 16 Jan 2019 by juhako

5: OCL Rules

    What is OCL?

    OCL (Object Constraint Language) is a query language originally developed for describing rules for UML models. OCL is managed by Object Management Group (OMG) and it is part of the UML standard. The official specifications can be found from OMG web pages at

    XMLdation service and OCL

    In XMLdation service XML Schemas are mapped as UML models, allowing restrictions to XML schemas to be created with OCL. Java code is generated based on the OCL definitions and executed against XML files in a validation process.

    The benefit of this is that we do not have to edit the underlying schema in any way; the schema and all of its restrictions stay as they are. Therefore creating and maintaining business rules only involves maintaining a series of OCL rules, which can be done with the XMLdation Studio.

    Content of this guide

    The purpose of this guide is to provide all necessary information to write business rules with OCL.

    The guide consists of following parts:

    1. Description of a rule
    2. Concept of context
    3. OCL statement
    4. OCL query
    5. Collections
    6. Relationships
    7. Actions


    In addition, following reference is included


    The collection of rules in example rules written in OCL should already help a lot when implementing new rules, as it includes examples of "real world" usage of business rules in payment messages. A more detailed usage for all available methods is listed in available methods of OCL base types.

    List of all available data types in XML schemas mapped to OCL data types states how different data types are interpreted by OCL.

    Reference schema

    Multiple pages within this section use a specifc pre-made schema as a reference to explain logic of rules. The schema and an example file is attached on this page. Below is a screenshot of the reference schema


    External links and further reading

    Please note that this section of the wiki only focused on OCL as a language to depict rules. XMLdation offers a tool for writing and maintaining business rules in OCL language in a tool called Studio. User guide on how to use Studio is also available in a separate wiki section. 

    Other sources providing information regarding OCL are below:

    OCL Rule User Guide, by Nomos Software, 2015

    OCL Quick Reference, by Eoin Woods, July 2005

    OCL Operations Reference, by Eclipse Foundation