CLiX - A Validation Rule Language for XML

Christian Nentwich
Systemwire Ltd.
christian@systemwire.com

Background

It is commonly accepted that "business rules" is an overloaded term that refers to a number of things: transformation rules, workflow control rules, and so on. The Constraint Language in XML (CLiX) deals with validation rules, that is, constraints that define the validity of XML documents. XML currently does not have such a constraint language, and the clean nature, use of other standards like XPath, and tight definition of the language using denotational semantics would make it an attractive validation rule language that can be easily integrated within the standards framework.

XML Schema is rarely sufficient to express all semantic constraints over XML files. Hardcoding is then not a good option since it removes the business logic and places it in the hands of developers and locks it into applications - the same argument that applies to other types of business rules. Existing options other than hardcoding at this point include Schematron, or CLiX. Schematron is simple and easy to use but has a number of shortcomings:

The CLiX Language

CLiX is a constraint language based on first order logic. It was first specified in 1998, when XML was not yet ubiquitous, in research at University College London. The language has since been developed and taken forward by Systemwire Ltd., a spin-off company that provides rule-based validation products around CLiX. Even though a commercial implementation is available, the language specification is published, and free for anybody to implement. It is hosted at http://www.clixml.org.

The following is an example of a CLiX rule over a financial trade expressed in the Financial Products Markup Language - one of the few standards that publish business rules, together with a CLiX reference implementation. The constraint expresses that a trade's effective date should be before its termination date:

<forall var="dates" in="//fpml:calculationPeriodDates>
  <less op1="$dates/fpml:effectiveDate/fpml:unadjustedDate" 
        op2="$dates/fpml:terminationDate/fpml:unadjustedDate"/>
</forall>

The CLiX language is a tight language that includes only a small number of well defined logical operators: the predicates "forall" and "exists", the boolean connectives and a number of predicates such as "equals", "less" and so on. The semantics of CLiX has been defined formally in a research setting and the language has been used in many application domains:

Our Position

XML needs a strong validation rule language. Validation is one piece of the overall task of bringing business rules to XML. We think that the CLiX language is a neat, well encapsulated and properly defined, and the best choice for semantic validation. Since it is already published as an open specification, it could be integrated into standards work. Systemwire, as a specialist provider of validation and data quality control software, would be pleased to help integrate a validation solution as part of an overall business rule framework for XML.