<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Demonstration of XML Validation Framework using OASIS CAM approach</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>David Webber</string-name>
          <email>drrwebber@acm.org</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>OASIS CAM TC Chair</institution>
          ,
          <addr-line>630 Boston Road, Suite M-102 Billerica, MA 01821</addr-line>
          ,
          <country>United States of America. David Webber</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>A XML validation approach using OASIS Content Assembly Mechanism (CAM) templates is presented. The approach permits support of a wide array of complex message exchanges with singleton template patterns and sets of context rules. The approach with CAM templates simplify and externalize the validation rules while allowing a validation gateway to act as a pass-through on information that is not directly relevant. The demonstration uses an open source implementation component built using Eclipse and Java technology to deliver the needed validation services.</p>
      </abstract>
      <kwd-group>
        <kwd>XML</kwd>
        <kwd>exchange</kwd>
        <kwd>validation</kwd>
        <kwd>XSD</kwd>
        <kwd>schema</kwd>
        <kwd>template</kwd>
        <kwd>framework</kwd>
        <kwd>OASIS</kwd>
        <kwd>CAM</kwd>
        <kwd>content assembly</kwd>
        <kwd>CCTS</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>In today's complex information exchanges with XML and associated large XSD
schema, coupled with an array of trading partners, it becomes a significant challenge
to support and maintain accurate handling of all incoming transactions. Currently,
XML schemas and DTDs provide the ability to validate, or verify, the structural
content of a XML document. The associated business content validation rules cannot
be adequately accommodated as part of XML schemas and hence use of OASIS CAM
templates provides the ability to express extended contextual handling rules.
With the advent of industry specific exchange standards expressed as XML schemas
the consumers and providers of information exchange services must comply with
these schemas to be conformant and interoperable with industry partners. However,
such industry specific schemas are loosely bound with minimal validations and can be
used for only structural validation of the incoming XML.</p>
      <p>The solution approach we present here is to implement the XML validation services
based on the OASIS Content Assembly Mechanism (CAM) specification. The OASIS
CAM template approach is based on a simple approach to XML content handling and
validation that allows businesses to create common interchange models for their
exchanges in XML. CAM templates support context-based rules, code-lists, and
cross-field validations.</p>
      <p>The solution includes CAM Studio (an Eclipse-based UI template editor) that is used
to define the CAM template. Then the CAMV validation engine provides a set of
open source Java APIs which are used to validate the XML with the specific compiled
CAM templates for run-time deployment in production environments. The CAM
Studio template editor supports adding custom XPath expressions to its generated
templates. Writing rules with XPath expressions has proven to be an extremely
powerful way of implementing the required XML handling and logic. These
validations prevent errors when the data is received by applications or components
that expect the data to be in a particular structure and comply with business content
validation rules.</p>
      <p>The demonstration will illustrate an exchange where two different exchange
patterns are required based on the context of an exchange partner. Sample XML
message instances show how dramatically different information exchange patterns
can be handled with ease using the CAM template approach.</p>
    </sec>
    <sec id="sec-2">
      <title>2 Implementation Approach</title>
      <sec id="sec-2-1">
        <title>2.1 Validation Template Generation</title>
        <p>Developing XML validation templates is discussed here. Figure 1 below shows
the Model, Author and Test, Deploy, and Monitor stages in the life-cycle of
developing the validation rules.</p>
        <p>Source: IBM Developer Works - http://www.ibm.com/developerworks/java/library/x-camval
2.1.1 Model Stage</p>
        <p>In this step the data entities and their data elements are identified along with their
corresponding validation rules. The required XML exchange schema is designed;
alternatively, the required elements are mapped to an existing industry standard
schema. The CAM Studio editor provides the capability to import and tailor existing
exchange schema this is discussed next stage.
2.1.2 Author and Test Stage</p>
        <p>CAM Templates are assembled or authored using the CAM Studio editor. There
are the three possible editor options provided to create a CAM template:
1. Create from scratch or hand-crafted
2. Use an existing XML Schema
3. Use an existing XML instance</p>
        <p>Once you create the CAM template, the next step is to review each required XML
element and attribute and their applicable validation rules. A panel in the editor
displays the rules for each template node. The Figure 2 here shows an example
template structure in the CAM Template Editor.</p>
        <p>While all such validation rules need not be binary in nature (that is, either pass or
fail), CAM supports classifying validation failures as Warnings and Informational
level reports. This feature comes in handy for scenarios where corrective action can
be taken at the service provider-end, modifying the payload to make the message
usable rather than rejecting the complete message. For example, a rule might require
the length of a particular comment field to be within 255 characters; however, a
request message should not be rejected when the length exceeds the maximum value,
but a warning should be sent to the message consumer specifying that only the first
255 characters will be used from the comment.</p>
        <p>As the warning is returned only if the length of specific element exceeds the
specified length, this rule is specified as conditional and an XPath expression is
created to perform the length check as depicted in Figure 3 screen capture of the
CAM Studio Editor expression entry wizard tool:
Once definition of the rules is completed then the template can be deployed.
2.1.3 Deploy Stage</p>
        <p>The CAM templates are compiled using the CAM Studio Editor before you use
them with the application run-time CAMV engine. The compiled format is the
condensed XML version of the original CAM template itself and is designed to
optimize performance of the CAMV validation engine. To compile the CAM
Template, select the menu option Tools &gt; Compile Template. This will generate the .cxx
file format of the template which will be used at run time.</p>
        <p>The CAMV validation engine offers a simple, open-source Java API which can be
used in any Java application to validate an input XML with the applicable CAM
template. The code snippets in Listing 1 illustrate the usage of CAMV:
Listing 1. Usage of CAMV API</p>
        <p>TemplateValidator tv = new TemplateValidator(templateDocument);
tv.setErrHandler(new ElementErrorHandler(tv));
boolean tvResult = tv.validate(ioReader);
if (tvResult){</p>
        <p>System.out.println("No errors, might be warnings.....");
}
List errList = tv.getErrors();
List warnList = tv.getWarnings();</p>
        <p>You can cache CAMV templates into memory to perform repeated validations and
not read the templates from the hard disk for each and every validation performed.
This reduces the disk I/O and significantly improves the performance and throughput.
Next we consider the verification of the rules scenarios in the template.
2.1.4 Monitor Stage</p>
        <p>During the monitor stage the performance of the templates is tracked and
adjustments performed to fine tune handling of actual exchange message instances.
By virtue of using the CAMV engine, you can now externalize all the validation
checks and need not embed them inside code or otherwise implement rules using
custom coding. During the monitoring cycle, you can meet the need for additional
validations by simply updating the validation templates to add additional validations
or remove existing ones. Then simply redeploy the compiled CAM template (.cxx
files).</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2 Further Template Considerations</title>
        <p>The CAM template format is represented in XML itself (see Appendix A for
example) and hence can be readily edited directly, as well as through using the CAM
studio editor. This flexibility permits development of sets of CAM templates to
match particular business application scenarios by cloning and adapting existing
exchange templates.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3 Conclusion</title>
      <p>Using the CAM template XML validation framework approach, you can enforce
validation checks consistently and then rapidly change rules to fine-tune message
handling to match particular partner exchanges and content. By externalizing the
validation rules, which in conventional deployment have been embedded deep inside
the backend application code, you have much better control and management along
with more predictable message handling. In addition the CAM rules templates can
optionally be shared with partners to facilitate better content handling alignment
across systems.</p>
      <p>With a more adaptive and fault tolerant process, the template based validation
framework is able to handle a wider variation in content and, hence, more easily
support a broad set of interaction partners with reduced support and maintenance
costs—which is the opposite of normal XML validation practice today.
The use of open source greatly facilitated collaboration on developing the solution
and integrating the CAMV engine into the deployment environment.</p>
      <p>Overall, this project demonstrated that innovative use of XML and dynamically
configurable XML rule templates can provide a better, more stable, faster, and
capable customer application experience than relying on static compiled code
resources alone.</p>
      <sec id="sec-3-1">
        <title>Appendix A – Example CAM template</title>
        <p>Schematron XML validation framework and ISO specification
http://www.schematron.com/resources.html
Reference Saxon XSLT engine implementation and Sourceforge project
http://saxon.sourceforge.net/</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>OASIS</given-names>
            <surname>Content Assembly</surname>
          </string-name>
          <article-title>Mechanism (CAM) technical specification</article-title>
          , version
          <volume>1</volume>
          .1,
          <string-name>
            <surname>published</surname>
            <given-names>Boston</given-names>
          </string-name>
          , MA - http://docs.oasis-open.org/cam (
          <year>2006</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <article-title>2. OASIS SET TC work on automated component mapping</article-title>
          - http://www.oasis-open.org/committees/set
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Kathuria</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roberts</surname>
            ,
            <given-names>M.E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Webber</surname>
            ,
            <given-names>D.R.R. :</given-names>
          </string-name>
          <article-title>XML Validation Framework using OASIS CAM (CAMV)</article-title>
          .
          <source>In: IBM DeveloperWorks</source>
          , http:/www.ibm.com/developerworks/library/x-camval/index.html
          <string-name>
            <surname>May</surname>
          </string-name>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>4. JCAM Engine with XML Editor / Validator: See information about the CAMV project at the SourceForge Web site</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>5. The OASIS CAM Wiki: Visit a resource site for users and developers of CAM templates and CAM processors</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Meet</surname>
            <given-names>CAM</given-names>
          </string-name>
          :
          <article-title>A new XML validation technology (Brian M. Carey</article-title>
          , developerWorks,
          <year>September 2009</year>
          )
          <article-title>: Read an introduction and overview of CAM.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Taking</surname>
            <given-names>XML</given-names>
          </string-name>
          <article-title>Validation to the Next Level: Introducing CAM: Read an article series representing CAM: The Missing Manual</article-title>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>