Data Format Description Language (DFDL) v1.0 Specification
OGF Proposed Recommendation GFD-P-R.174, January 31, 2011


7.3 The dfdl:assert Annotation Element

The dfdl:assert annotation element is used to assert truths about a DFDL model that are used only when parsing to ensure that the data are well-formed. These checks are separate from validation checking and are performed even when validation is off. This distinction is needed to ensure that switching validation off does not affect parsing.

Examples of dfdl:assert elements are below:
<dfdl:assert message="Value is not zero." test="{ ../x ne 0}" />

<dfdl:assert message="Precondition violation." >
  <[CDATA[ {../x le 0 and ../y ne "-->" and ..y ne "<!—" }]]>
</dfdl:assert>


<dfdl:assert message="Postcondition violation."  testKind='expression'>
  {../x ne "’"}
</dfdl:assert>

7.3.1 Properties for dfdl:assert

DFDL asserts can be placed on components within a DFDL model. These dfdl:asserts contain a test expression or a test pattern. The dfdl:assert is said to be successful if the test expression evaluates to true or the test pattern returns a non-zero length match, and unsuccessful if the test expression evaluates to false or the test pattern returns a zero length match. An unsuccessful dfdl:assert causes a processing error.

The dfdl:testKind attribute specifies whether an expression or pattern is used by the dfdl:assert. The expression or pattern can be expressed as an attribute or as a value.
<dfdl:assert  test="{test expression}" />
<dfdl:assert > 
            {test expression} 
</dfdl:assert>

It is a schema definition error if a property is specified in more than one form.

It is a schema definition error if both a test expression and a test pattern are specified.

A dfdl:assert can be an annotation on:

More than one dfdl:assert may be used at an annotation point. The dfdl:asserts will be evaluated in the order defined in the schema.

Property Name

Description

testKind

Enum (optional)

Valid values are 'expression', 'pattern'

Default value is 'expression'

Specifies whether a DFDL expression or DFDL regular expression is used in the dfdl:assert.

Annotation: dfdl:assert

test

DFDL Expression

Applies when dfdl:testKind is 'expression'

A DFDL expression that evaluates to true or false. If the expression evaluates to true then parsing continues. If the expression evaluates to false then a processing error is raised.

Any element referred to by the expression must have already been processed or is a descendent of this element.

The expression must have been evaluated by the time this element and it descendents have been processed.

If a processing error occurs during the evaluation of the test expression then the dfdl:assert also fails.

It is a schema definition error if dfdl:test is the empty string and the value is not specified and dfdl:testKind is 'expression' or not specified

Annotation: dfdl:assert

testPattern

DFDL Regular Expression

Applies when dfdl:testKind is 'pattern'

A DFDL regular expression that is executed against the data stream starting at the start of the component on which the dfdl:assert is positioned.

If the length of the match is zero then the dfdl:assert evaluates to false and a processing error is raised.

If the length of the match is non-zero then the dfdl:assert evaluates to true.

If a processing error occurs during the evaluation of the test regular expression then the dfdl:assert also fails.

It is a schema definition error if dfdl:testPattern is the empty string and the value is not specified and dfdl:testKind is 'pattern'.

Annotation: dfdl:assert

message

String

Defines text to be used as a diagnostic code or for use in an error message. The DFDL specification does not specify how a DFDL processor uses this message text.

Annotation: dfdl:assert

Table 9 dfdl:assert properties

 


Copyright (C) Open Grid Forum (2005-2010). All Rights Reserved.

This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the OGF or other organizations, except as needed for the purpose of developing Grid Recommendations in which case the procedures for copyrights defined in the OGF Document process must be followed, or as required to translate it into languages other than English.