Page last modified 11:39, 3 Feb 2016 by Antero

4. Message location Redirected from User guide for OCL rules in XMLdation environment/4. Message location

    Table of contents
    Description

    Content within message location is executed whenever OCL statement returns false, i.e. when error message needs to be displayed in the validation report. Their purpose is to locate a defined position of the XML-file, so that error message is shown wherever the creator of the rule sees fit.

     

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

    Usage

    Message location is defined with OCL-queries, thus containing similar code than OCL-statement field. However, due to the nature of their purpose, the code is often simpler than the code in OCL-statement. They could be thought as an address where to point the error message, and often it is enough to state the desired element in an xPath style, starting the query with "self" which points at context, and separating elements using 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 defined, 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