Redirected from User guide for OCL rules in XMLdation environment/4. OCL-query4. Message location
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.
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.
Below example is used in the OCL statement section of this wiki.
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"|
|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.
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.