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.
Before you can run the following commands you will need to download and install the ANT engine from
Type the following command line you will see the output of your file as CAM requires it.
ant -Dtemplate=newTemplate.cam -Doutput=TemplateOutput.cam -f jcam.xml new
You will see that all the element and attribute contents have been replaced by '%%'.
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.
Use the following command to validate an XMl document
ant -Dtemplate=Template.cam -Dxmlfile=XMLFilename.xml -Doutput=ResultXML.xml -f jcam.xml run