Page last modified 14:34, 31 Dec 2015 by Antero

4. Message location

    Table of contents

    Version as of 17:04, 7 Dec 2021

    to this version.

    Return to Version archive.

    View current version

    Description

    OCL-queries are executed whenever OCL-statement returns false. Their purpose is to locate a defined occurrence from the XML-file, so that error message is shown in wherever the creator of the rule sees fit.

    OCL-queries are optional. Whenever a query is not defined and OCL-statement returns false, the defined error message is shown in the location of context.

    Usage

    The usage of queries in XMLdation environment is often simple; they could be thought as an address where to point the error message, and often it is enough to list the desired element in an xPath style, but replacing context with "self" and separating elements using a dot notation.

    Examples

    Below example is used in the OCL-statement section of this wiki.

    Context: HeaderType1
    Description

     

    Rule defines a specific value for Debtor/Name when Debtor / Name is given.

    OCL-statement self.Debtor.Name->size() = 1 implies self.Debtor.Name = "The initiator"
    OCL-Query self.Debtor.Name
    Message Debtor / Name is not The initiator

     

    Here OCL-query is defiend to be self.Debtor.Name. This means that the error message is shown in that location, under Debtor / Name. Without the query defiend, error message would be shown on self, on element Header.

      <Header>
        <Id>1.0</Id>
        <TimeStamp>2015-07-03T12:17:50</TimeStamp>
        <ControlSum>2</ControlSum>
        <NumberOfTransactions>1</NumberOfTransactions>
        <Debtor>
          <Name>Something else</Name> <!-- error message is shown here in XMLdation service -->
        </Debtor>
      </Header>

     

    In this case, if the error message would be shown on header it most likely would not confuse the user, as the schema is small and it is fairly easy to locate the erroneous element and no other errors are present. In bigger shemas with multiple rules, however, queries help maping the validation report clear.

    Menu