OASIS CAM Concepts 101

Firstly you need to know that the CAM editor is dedicated to generating valid CAM Templates that conform to the OASIS CAM standard.

The Standard defines a template as having four main parts:

  1. The CAM Template Header.
  2. The Assembly Structure or Structures
  3. The Business Context Rules
  4. Extension points- also known as plug-ins.

Before starting it is worth understanding the basic ideas behind CAM.  These are:

  1. A mechanism that allows XML content to be validated using simple rules including both structure and field contents.
    1. The Structures are defined by example.
    2. Rules are linked to the structure using simple XPath 1.0 paths.
    3. Conditions are expressed as XPath conditions similar to those used by XSLT test function.
  2. It allows context to be set via parameters passed into the the processor at runtime.
  3. It enable cross-field validation rules to be defined. i.e. if fieldX contains 2 then fieldY must contain 3.  This is not possible in most XML schema languages.
  4. It allow pre and post processing to take place using powerful extension functions. i.e:
    1. These functions can be checks with data dictionaries in registries of conversion of the XML before or after processing.
    2. This conversion could be a simple XSLT Stylesheet applied to the XML input file after processing ready for the next task in the processing stack.

The Header

Fig 1.  Parts of an Example

Namespaces

Some important issue to note about namespaces.

  1. It is worth noting that the namespaces that occur in the Examples included in the Assembly Structures need to be moved to the top of the Template. (This is done automatically if you use the New Template from XML option).  If you do not the XPath expressions in the Business Rules section will not be able to refer to the namespace. 
  2. A further thing to note is that the XML in the Assembly Structure section must not use Anonymous namespaces.  If no namespaces are used in the XML that is fine.  But any that are used must be associated with a prefix otherwise the processor will not be able to associate the rules with the correct elements and attributes.  Again this is handled automatically if you use the New Template from XML option. Any anonymous namespaces are given dummy 'asN:' style prefixes which can be edited from the Namespace tab.

Imports and Properties

The current version of the jCAM processor does not use these two concepts.  They will be ignored.  This does mean that $property tags will be ignored and may cause the XPaths to be handled incorrectly.

 

Assembly Structures

Fig 1.  The Assembly Structure Section

Assembly Structures are simple XML examples.  The first rule that CAM assumes is that unless any other rule is defined that every element or attribute in the XML structure is mandatory.  It contents may vary but the element or attribute must exist in the order provided.  (CAM does not allow unordered content).  Each field may contain variable contents by simply either replacing the node contents with '%%' or by surrounding the contents with % signs.  This latter technique can be useful when creating rules associated with the nodes as the contents can act as an aide memoir as to what rules need to be applied.  (Using the New Template from XML option adds the surrounding % signs automatically.

CAM allows more than one structure to appear in the Template.  When processing against the template the structure ID must be passed in to indicate the required Structure to use as the validation example.  The advantage of having more than one Structure is that quite often rules are common against more than one structure.  The disadvantage is that the ID must be passed in at runtime.

Business Context Rules Section