# FpML XQuery Validation Rules

Copyright FpML

Version 1, for FpML 4-5

## Abstract

This document is the readme for the FpML XQuery Validation Rules.

This document will show you how to use the FpML XQuery Validation Rules (known informally as the XQuery Rules for short). The document explains why the rules exists, using them, and their future path.

XQuery is a W3C language for querying XML documents. XQuery is built on the well known XPath.

## Background to the XQuery Rules

The FpML Validation Rules are a normative part of the definition of FpML. The Validation Rules specify constraints on messages (static constraints) and between messages (dynamic constraints). These constraints are expressed as rules. The rules are represented in a combination of XPath 2.0 and natural language (English).

The use of natural language causes the rules to be imprecise. The precise definition is unclear and consequently people have different interpretation of the rules. FpML has begun to use more and more XPath to define the Validation Rules and this has substantially improved precision. These XQuery Rules complete that process by expressing the rules completely in the precise language of XPath using XQuery. The meaning and interpretation of the Validation Rules is made unambiguous.

The XQuery Rules were as a side-effect of cleaning up the Validation Rules, while working in the FpML Working Groups. The rules are packaged up here for anyone to use (in compliance with the FpML license).

A common fallacy is that the FpML Validation Rules are "policy" or "market practise". Both policy and market practise can be expressed well in the form of rules, but that does not mean all rules are policy or market practise. The FpML Validation Rules are part of the type system definition of the FpML schema.

Another fallacy is that XQuery Rules are formal. They are not formal, merely precise.

## Usages for the XQuery Rules

The most common usage for the XQuery Rules is to test example FpML documents during software analysis and development. Business analysts and software developers test documents they have received or created. Common GUI tools such as Altova's XML Spy can be used to run the rules.

The second common usage is in defensive programming. This is where a software system validates data it receives or sends to eliminate a many prolems as possible before they get 'downstream'. Common tools such as Saxonica's Saxon-SA provide a high speed validation capability.

#### Scope

This version of the XQuery Rules covers all Validation Rules.

## Running the XQuery Rules

#### Files in the Package

- fpml-validation-rules.xq - this is the main XQuery file. It references product-specific Xquery files.
- Validation.xsd - this is the XSD schema that describes the results of running the rules.
- ExampleValidationResults.xml - this is an example results file.
- readme.html - this readme file.
- xquery.zip - download all the files.

#### Verified XQuery implementations

The XQuery Rules have been tested with the following tools:

- Altova XML Spy version 2008 release 2
- Saxonica Saxon-SA 9.0.0.4

The XQuery Rules are schema-aware and requires the use of a schema-aware XQuery processor.

#### XQuery version

The XQuery Rules are written in XQuery 1.0.

## Future Plans

The future direction of the XQuery Rules.

#### XML Schema 1.1

XML Schema 1.1 includes a new <xs:assert> statement that can be used to assert constraints in XPath. These XQuery Rules are written in XPath and could be added into the FpML XSD files as <xs:assert> when FpML upgrades to XML Schema 1.1