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:
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.)findChildren ( element, elementTypeSpec ).count()
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 returntrue
if the element should be counted andfalse
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 returns0
.
Examples:
Returns the number of all "Method"
and "Field"
children of
the current generator context element:
Returns the number ofcountChildren("Method | Field");
"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}