Returns the nearest predecessor of the specified element which complies with one of the specified Element Types.
findElementByType (
element.predecessors,
elementTypeSpec
)
Parameters:
element
If not specified, the generator context element is assumed, which is the same as the call:
findPredecessorByType (
contextElement,
elementTypeSpec
)
GOMContext.contextElement
Note: When this parameter is null
, the function just returns null
as well.
elementTypeSpec
The returned element will comply with one of the target Element Types.
Note: When the list contains names of non-existent Element Types, the generator will raise an error.
elementTypes
In this case, the Element Types are specified via an array of
GOMElementType
objects representing each Element Type.
The array should be created with a function-call-like construct looking as
GOMElementType[] (
...
)
GOMElementType
objects listed inside the round brackets and separated with commas.
The difference from the 'elementTypeSpec'
parameter is that,
there is no need to parse the Element Type specification
(and find the corresponding Element Types) during the function call,
which is time-consuming.
Instead, you can prepare/parse the necessary Element Types preliminary
using getElementTypes()
function, and then just pass them via this parameter.
This should improve performance when the function is called repeatedly with the same target Element Types.
Notes:
'elementTypeSpec'
parameter.
In that case, the Element Type specification will be parsed/prepared only once
when parsing the whole expression.
GOMElementType[]
array is null
or empty,
the function will return null
.
getElementTypes(), findElementByType(), GOMElement.predecessors