Configuration for Processing CALS Tables

Introduction

This page gives a detailed explanation of the settings used in a DCP file when processing CALS tables.  These are summarised in the DCP Schema Guide.

The use of CALS tables is explained in the page Comparing Document Tables (CALS or HTML)

Note that this page is only applicable when using the Document Comparator.

Validation

CALS tables are validated by a Schematron file.  This is published in GitHub. There are different ways to configure the messages, this is explained below. CALS tables are those that have a <tgroup> element.

Each message includes the XPath of the element concerned.  This allows the identification of the erroneous element in the input file within an XML editor.  Alternatively you may search for the phrase CALS Table Validation Warning in the result document.

The CALS reference refers to page https://www.oasis-open.org/specs/tm9502.html. The Semantic description for the CALS table model section has a number of tables.  For example, reference T5R1 refers to Table 5, Row 1.

Configuration 

processCalsTables

true (default)

A table has to have a <tgroup> to be seen as a CALS table.

false

If you have no CALS tables in the input documents, the comparison may be faster if you switch CALS table processing off.

Use false if you have <tgroup> elements that are not part of a CALS table.

warningReportMode

processingInstructions (default)

By default the CALS Table Validation Warning appears in a processing instruction.  In a large file you could search for the string CALS Table Validation Warning.

Sample result file showing processing instruction
      <tgroup deltaxml:deltaV2="B" cols="3"><?dxml_warn CALS Table Validation Warning for Input B:
In /Q{}article[1]/Q{}table[1]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[2] the column specified by the namest attribute (c) must be to the left of the column specified by nameend (b) CALS-T10R4F?>
        <colspec colnum="1" colname="a"/>
        <colspec colnum="2" colname="b"/>
        <colspec colnum="3" colname="c"/>
        <tbody>
          <row><entry colname="a" morerows="2"/><entry namest="c" nameend="b"/></row>
          <row><entry colname="b"/><entry colname="c" morerows="1"/></row>
          <row><entry colname="b"/></row>
        </tbody>
      </tgroup>

message

When using a value of message  for this parameter and running from the command line you will obtain output like this if there is an error:

Sample Command line output when warningReportMode is message
DeltaXML Command Processor, version: 2.1
Copyright (c) 2000-2015 DeltaXML Ltd. All rights reserved.
Using: XML-Compare, version: 10.1.1

CALS Table Validation Warning for Input A=B: The @morerows on /Q{}article[1]/Q{}table[4]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[1] needs to be a non-negative integer CALS-T10R11


comments

If you set the warningReportMode to comments then and XML comment is inserted after a <tgroup> that has an error.

Sample result file showing comments
      <tgroup deltaxml:deltaV2="B" cols="3"><!--CALS Table Validation Warning for Input B:
In /Q{}article[1]/Q{}table[1]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[2] the column specified by the namest attribute (c) must be to the left of the column specified by nameend (b) CALS-T10R4F-->
        <colspec colnum="1" colname="a"/>
        <colspec colnum="2" colname="b"/>
        <colspec colnum="3" colname="c"/>
        <tbody>
          <row><entry colname="a" morerows="2"/><entry namest="c" nameend="b"/></row>
          <row><entry colname="b"/><entry colname="c" morerows="1"/></row>
          <row><entry colname="b"/></row>
        </tbody>
      </tgroup>


The expression can be copied and pasted into an XPath builder in an XML editor such as oXygen and, with the focus on the file with the problem, the element concerned will be highlighted.

For both PIs and comments the message will appear in the tgroup with the problem.

Note that both the comments and processingInstructions options include the wording CALS Table Validation Warning so that searching the result file for this phrase will show the errors. 

invalidCalsTableBehaviour

propagateUp (default)

This propagates the error up to the next tgroup.  Remember that the XML will not be considered to be a CALS table if there is no tgroup element.

Sample default result
      <tgroup deltaxml:deltaV2="B" cols="3"><?dxml_warn CALS Table Validation Warning for Input B:
In /Q{}article[1]/Q{}table[1]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[2] the column specified by the namest attribute (c) must be to the left of the column specified by nameend (b) CALS-T10R4F?>
        <colspec colnum="1" colname="a"/>
        <colspec colnum="2" colname="b"/>
        <colspec colnum="3" colname="c"/>
        <tbody>
          <row><entry colname="a" morerows="2"/><entry namest="c" nameend="b"/></row>
          <row><entry colname="b"/><entry colname="c" morerows="1"/></row>
          <row><entry colname="b"/></row>
        </tbody>
      </tgroup>

compareAsXml

This processes the table as if it is just xml and not a table.  The warning is still given, defaulting to a processing instruction on the <tgroup>

Sample result file when behaviour is set to xml
    <tgroup deltaxml:deltaV2="A!=B" cols="3">
      <?dxml_warn CALS Table Validation Warning for Input B:
In /Q{}article[1]/Q{}table[1]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[2] the column specified by the namest attribute (c) must be to the left of the column specified by nameend (b) CALS-T10R4F?>
...
          <entry deltaxml:deltaV2="A!=B">
            <deltaxml:attributes deltaxml:deltaV2="A!=B">
              <dxa:namest deltaxml:deltaV2="A!=B">
                <deltaxml:attributeValue deltaxml:deltaV2="A">b</deltaxml:attributeValue>
                <deltaxml:attributeValue deltaxml:deltaV2="B">c</deltaxml:attributeValue>
              </dxa:namest>
              <dxa:nameend deltaxml:deltaV2="A!=B">
                <deltaxml:attributeValue deltaxml:deltaV2="A">c</deltaxml:attributeValue>
                <deltaxml:attributeValue deltaxml:deltaV2="B">b</deltaxml:attributeValue>
              </dxa:nameend>
            </deltaxml:attributes>
          </entry>
...
    </tgroup>

fail

This will fail with a message starting Detected invalid table(s), for example:

Sample Output when behaviour is set to fail
java -jar /usr/local/deltaxml/DeltaXML-XML-Compare-10_1_1_j/command-10.1.1.jar compare CALS-fail  valid.xml invalid.xml result-fail.xml
DeltaXML Command Processor, version: 2.1
Copyright (c) 2000-2015 DeltaXML Ltd. All rights reserved.
Using: XML-Compare, version: 10.1.1

Comparison runtime fault: Exception thrown when attempting to run the 'result/0-output-part-1/4-dxml-calsTable/7-validity-reporter' step (source: 'net.sf.saxon.s9api.XsltExecutable@102dff25')

Exception Stack Trace:

com.deltaxml.cores9api.FilterProcessingSingleException: Exception thrown when attempting to run the 'result/0-output-part-1/4-dxml-calsTable/7-validity-reporter' step (source: 'net.sf.saxon.s9api.XsltExecutable@102dff25')
	at com.deltaxml.cores9api.RunnableFilterChain.c_a(RunnableFilterChain.java:30)
	at com.deltaxml.cores9api.RunnableFilterChain.c_a(RunnableFilterChain.java:172)
	at com.deltaxml.cores9api.PipelinedComparatorS9.c_b(PipelinedComparatorS9.java:387)
	at com.deltaxml.cores9api.PipelinedComparatorS9.c_a(PipelinedComparatorS9.java:707)
	at com.deltaxml.cores9api.DocumentComparator.c_a(DocumentComparator.java:679)
	at com.deltaxml.cores9api.AbstractComparator.compare(AbstractComparator.java:90)
	at com.deltaxml.cores9api.DocumentComparator.compare(DocumentComparator.java:278)
	at com.deltaxml.cmdline.PipelinedTextUI.c_b(PipelinedTextUI.java:345)
	at com.deltaxml.cmdline.PipelinedTextUI.<init>(PipelinedTextUI.java:389)
	at com.deltaxml.cmdline.PipelinedTextUI.main(PipelinedTextUI.java:97)
Caused by: net.sf.saxon.trans.XPathException: Detected invalid table(s):
Input B: In /Q{}article[1]/Q{}table[1]/Q{}tgroup[1]/Q{}tbody[1]/Q{}row[1]/Q{}entry[2] the column specified by the namest attribute (c) must be to the left of the column specified by nameend (b) CALS-T10R4F


calsValidationLevel

strict

relaxed (default)

If there's an error with spanname being used in thead or tfoot when colspec is defined, then no error will be reported in relaxed mode.  In strict mode you will see an error like:

Error given in strict validation mode
Use of the spanname attribute in a thead/tfoot is not allowed when local colspec elements are defined.

Relaxed validation does not give any error for this tgroup even though the <thead> has both a colspec and a spanname.

Sample tgroup illustrating the difference between 'strict' and 'relaxed' validation
      <tgroup cols="2">
        <colspec colnum="1" colname="a"/>
        <colspec colnum="2" colname="b"/>
        <spanspec spanname="ab" namest="a" nameend="b"/>
        <thead>
          <colspec colnum="1" colname="a"/>
          <colspec colnum="2" colname="b"/>
          <row><entry spanname="ab"/></row>
        </thead>
        <tbody>
          <row><entry spanname="ab"/></row>
        </tbody>
      </tgroup>

There are other tests that are only reported when validatinLevel is strict.  These are shown in the Schematron file cals.sch with an attribute on the assert element role="warning"


#content .code