What are element parent and ancestors?

One of the key principles of DocFlex technology consists in the mapping of any external data source to a certain virtual XML-like representation (called Data Source Model or DSM) made of elements and attributes. That representation allows processing of each particular data source in a very uniform way using templates.

Besides elements and their attributes, such a mapping always includes the notion of child elements.

When some object of the external data source, which is mapped to element1, aggregates in itself another object mapped to element2, then, according to the mapping, the element2 may be considered as a child of element1. In that case, element1 will be parent of element2.

It is always possible to find for a given element all its children that comply with a particular Element Type. This is guaranteed by any DSM Type.

However, the opposite is not always true. For some special data sources, it is not always possible to find for a given element another DSM element the child of which it is, even if such an element (the parent) does exist.


Currently, resolving of parent elements is supported for Doclet DSM in DocFlex/Javadoc and XML DSM in DocFlex/XML.

When resolving of parent elements is supported, the parent of a given element can be obtained via its GOMElement.parent property. For example, if an element has children of SomeElementType, the following expression must return true:


child = element.findChild ("SomeElementType");
child.parent.id == element.id
The notion of ancestor element is derived from the notion of parent element. When a given element has a parent, then all members of the chain:

{ element->parent,
  parent->parent,
  parent->parent->parent,
  ... }
are ancestors of that element (the sequence repeats until reaching null).

See Also:

GOMElement.parent, GOMElement.ancestors, findAncestor(), findChildren()