Tests if the specified element complies with one of the specified Element Types. If true, the function returns the same element, otherwise it returns null.

Basically, this function does the same as the following expression:

element.instanceOf(elementTypeSpec) ? element : null
Why is a special function needed for this? Because it works essentially as a typecast operator!

Suppose, you have received in your element variable an element that, you know, represents an instance of some 'MethodDoc' type. You also know that all elements of MethodDoc type must have a 'signature' attribute. So, you expect that the call like

element.getAttrValue("signature")
will always return the value of that attribute. Unfortunately, it may be not so in every situation.

The actual result returned by such a call may depend on what is known about that element to the generator. It may be so that the way you have obtained that element suggests to the generator only that this element has Doc type. Doc is an ancestor of MethodDoc type. However, not every Doc element has a signature attribute. If on this stage, the generator knows about your element only that it has Doc type, the expression above may return null. This is because without knowing the exact type, the generator may not know how to retrieve a particular attribute associated with this type. The problem may be solved with the following expression:

checkElementType(element, "MethodDoc").getAttrValue ("signature")
That expression will always return the correct result. The call of the checkElementType() will cause the generator to ensure that this particular element complies with MethodDoc type. After that, the element will be resolved against this type and may be fully processed according to the type specification.

The necessity to have each element to be resolved against a particular Element Type to be able to process it accordingly (even though, it may be known from the start that the element must comply with that type) depends on the underlying DSM (Data Source Model) and its driver. Some DSMs have all their elements automatically resolved with their exact types, others have not. Please, read more detail about this in "What are Element Types?" section below.

Parameters:

element

The element whose type needs to be resolved.

If this parameter is not specified, the generator context element will be assumed, i.e. the same as the call: contextElement.checkElementType(elementTypeSpec)

elementTypeSpec
The list of the target Element Types (see "Specifying Matching Element Types" below).

Returns:

The passed element if it complies with at least one of the specified Element Types; null otherwise (or in the case element == null)

See Also:

instanceOf(), resolveElementType(), findElementType(), GOMElement.elementType

${include ../../../refs/matching_ets_spec.htm}

${include ../../../refs/element_types.htm}