One Minute Tutorial

Creating a CAM Template

Cam requires the creation of a CAm template before any work can take place. The simplest template is as follows:

<?xml version="1.0" encoding="utf-8"?>
<as:CAM CAMlevel="1" version="1.0" 
 xmlns:as="http://www.oasis-open.org/committees/cam" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <as:Header>
   <as:Description>The simplest of Cam Templates</as:Description>
   <as:Owner>Your Name</as:Owner>
   <as:Version>0.1</as:Version>
   <as:DateTime>2003-05-20T17:00:00</as:DateTime>
  </as:Header>
  <as:AssemblyStructure>
   <as:Structure taxonomy="XML">
        <as:include raw="true">full_path/your_file.xml</as:include>
   </as:Structure>
  </as:AssemblyStructure>
  <as:BusinessUseContext>
    <as:Rules>
      <as:default>
        <as:context>

        </as:context>
      </as:default>
    </as:Rules>
   </as:BusinessUseContext>
</as:CAM>

You place the path and the name of your file in the include element and your file will be included as the example for CAM to use.

Type the following command line you will see the output of your file as CAM requires it.

jcam -t -T newTemplate.cam -O TemplateOutput.cam

Or you can use the following if your example uses namespaces.

jcam -t -s -T newTemplate.cam -O TemplateOutput.cam

You will see that all the element and attribute contents have been replaced by '%%'.

Adding Rules

Next you need to add rules to your template. These will go between the as:context elements.

note: By default CAM assumes that all elements and attribute are mandatory unless a rule declares otherwise.

Rules take the format:

<as:constraint action="functionName(xpath)"/>

CAM provides a number of functions some examples might be:

<?xml version="1.0" encoding="utf-8"?>
<as:CAM CAMlevel="1" version="1.0" 
  ...
  <as:BusinessUseContext>
    <as:Rules>
      <as:default>
        <as:context>
          <as:constraint action="makeOptional(//BuyerAddress)"/>
          <as:constraint action="setValue(/root/@version,'1.0')"/>
        </as:context>
      </as:default>
    </as:Rules>
   </as:BusinessUseContext>
</as:CAM>

See Function Definitions to see the complete list.

Validating a Document

Use the following command to validate an XMl document

jcam -c -T Template.cam -X XMLFilename.xml -S ResultXML.xml