Counts all elements that are children of the specified element and comply with the specified target Element Type(s).

This function returns the same result as the following call:


findChildren (
  element,
  elementTypeSpec
).count()
Since counting the element's children of a certain type is needed rather frequently, this dedicated function has been added. (In addition, it will work a bit faster than the expression above.)

Parameters:

element

The element whose children are interested.

If not specified, the generator context element is assumed, i.e. the same as the call: contextElement.countChildren(elementTypeSpec)

See Also: GOMContext.contextElement

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

All counted elements should comply with at least one of the target Element Types.

filterQuery
Specify an additional condition on the counted elements.

This should be a boolean subquery created with BooleanQuery() function. The subquery will be processed against each initially selected element. It must return true if the element should be counted and false if it should be ignored. The tested element is passed as the generator context element.

Returns:

The number of found child elements.

Note: If element == null, the function returns 0.

Examples:

Returns the number of all "Method" and "Field" children of the current generator context element:

countChildren("Method | Field");
Returns the number of "Class" children of the current context element, whose "name" attribute has the value starting with "ABC":
countChildren("Class", BooleanQuery (
  getAttrStringValue("name").startsWith("ABC")
));

See Also:

findChildren(), countElementsByLPath(), BooleanQuery()

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

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