How-To Work with Sections
Back to current version Restore this version

Introduction#

In KnowWE the content of an article is managed as a hierarchical structure of the content elements. Every node of that tree contains a particular fragment of the source text of the page. We call such a node a Section. No matter what kind of extension for KnowWE should be implemented, sections will play a fundamental role in any case. Therefore handling, searching, navigation, and modification of sections are hot topics in KnowWE programming.

Finding other sections from a given section#

The class Sections provides numerous static utility methods for working with sections. Often it is necessary to find a section of a particular type, which is an ancestor or successor of a given section. For this purpose, multiple methods in the class Sections are provided starting with findAncestor or findSuccessor respectively. If a single section object is returned, it is the first matching section found. If multiple sections are returned, they are ordered as detected by the traversing algorithm. The search for ancestors ascends straight from the given section towards the root section. The search for successors runs in depth first search manner starting at the given section. If only a search for direct successors is desired, methods starting with findChild are provided.

Editing page contents#

Often it is required to modify the source content of a page.