A recent addition (from version 0.9.16.0 onwards) is the ability to specify within an XML file the location of the CAM template that should be used to check the XML file. This works in a similar manner to the XML schema xsi:schemaLocation attribute.
Within the XML file a new attribute needs to be added to the XML file root node. This attribute is called templateLocation and belongs to the namespace http://www.oasis-open.org/committees/cam/instance. The normal prefix for this is asi.
An example would be:
<?xml version="1.0" encoding="UTF-8"?> <ex:example xmlns:ex="http://jcam.org.uk/example" xmlns:asi="http://www.oasis-open.org/committees/cam/instance" asi:templateLocation="example.cam"> <ex:test name="Fred"> <ex:inside>value</ex:inside> <ex:inside2> <ex:child>must exist</ex:child> </ex:inside2> </ex:test> </ex:example>
JCAM will check to see if the file exists if it does not it will look in the same location as the XML file. So in the example above JCAM will look in the same diretory as the XML file. The templateLocation can be a URL.
Unlike XML Schemas it is possible in CAM to pass in parameters to the checking process and there by influence the checks that are applied. This is done in the XML file by including a attribute for each parameter. The attribute should be in the same namespace as the templateLocation attribute and should be called the same name as the Parameter. So if there was a parameter called 'country', then an attribute 'asi:country' would have to be included as a child of the root node.
An example with parameters would be :
<?xml version="1.0" encoding="UTF-8"?> <ex:example xmlns:ex="http://jcam.org.uk/example" xmlns:asi="http://www.oasis-open.org/committees/cam/instance" asi:templateLocation="example.cam" asi:country="UK"> <ex:test name="Fred"> <ex:inside>value</ex:inside> <ex:inside2> <ex:child>must exist</ex:child> </ex:inside2> </ex:test> </ex:example>