c:assert

<c:assert
  test = expression(Boolean)
  value? = expression >
  <!-- Content: sequence-constructor -->
</c:assert>

Checks for a condition and signals a message if the condition is false.

Category
instruction
Permitted parent elements
Any XCST element whose content model is sequence-constructor
Any literal result element

Attributes

test The condition to check for.
value A message to signal.

In addition to the attributes in the preceding table, there are a number of standard attributes that may appear on any XCST element.

Remarks

c:assert is compiled into a Debug.Assert call.

Example
<c:template name='paint'>
   <c:param name='colors' as='string[]'/>

   <c:assert test='colors?.Length > 0'>At least one color expected.</c:assert>
   ...
</c:template>
Note: Differences with xsl:assert

Unlike xsl:assert, c:assert does not guarantee that an exception will be thrown. An assertion can fail silently without interrupting the evaluation of the containing sequence constructor.

Error Conditions

It is a compilation error if the value attribute is present when the content of the element is non-empty.

See Also