# FpML 5.3 Validation Rules - Rules for Messaging

This section is the constraints that implement the Business Process definition and Messaging definition in the FpML 5.3 Working Draft #2.

These constraints apply to the set of all known messages to validate the Business Process and Messaging definitions. The rules are tested by applying to the collection of all messages available, both sent and received. Each message is referred to as a "document", as this meets the requirement to use XPath 2.0 for paths.

The constraints are written as invariant rules that return "false" when they are failed and "true" when they are satisfied. The constraints are written to accommodate the open world assumption that there may be other messages that are not yet known about. For example messages that have not yet been sent or arrived are unknown.

A subset of constraints is identified as "Warnings". These constraints are used when knowledge from a message is expected but absent and it is impossible to distinguish between the messages being incorrect and the message not yet being known about. For example a Request might not yet be known about to match to a Response.

The constraints that are not "Warnings" are termed "Mandatory" constraints, which is consistent with all other rules.

## Content

- Namespace
- Functions
- Rules
- Rules with comments
  - msg-1
  - msg-2
  - msg-3
  - msg-4

## Namespace

default element namespace = http://www.fpml.org/spec/fpml-5-3-2-wd-2

namespace xs = http://www.w3.org/2001/XMLSchema

## Functions

The following shared functions are used in the rules.

- fpml:deep-equal

## Rules

#### Unique contexts:

- collection(): msg-1 msg-2 msg-3 msg-4
- Deprecated rules
- Removed rules

msg-1 (Mandatory)
English Description:
Context: collection()
Every /FpML/header/messageId must be unique. The comparison function for correlation is fpml:deep-equal()
Comment: MessageId is unique
msg-2 (Warning)
English Description:
Context: collection()
every /FpML/header/inReplyTo must correlate to one /FpML/header/messageId. The comparison function for correlation is fpml:deep-equal()
Comment: A reply must be in response to a message. You may not yet have the message being responded to.
msg-3 (Mandatory)
English Description:
Context: collection()
every /FpML/header/inReplyTo must not correlate to a /FpML/header/messageId in the same document. The comparison function for correlation is fpml:deep-equal()
Comment: A message cannot reply to itself.
msg-4 (Mandatory)
English Description:
Context: collection()
every /element(*, MessageRejected)/header/inReplyTo must not correlate to /element(*, MessageRejected)/header/messageId. The comparison function for correlation is fpml:deep-equal()
Comment: If you know it is a MessageRejected message then it may not be rejected.

#### Deprecated rules

#### Removed rules