Login  Register

Access a sublevel from sections collected with findBy

Posted by ch007m on Apr 09, 2020; 3:29pm
URL: https://discuss.asciidoctor.org/Access-a-sublevel-from-sections-collected-with-findBy-tp7869.html

Hi

Is it possible to access easily a sublevel section from a node calculated using findBy ?

Example
== Introduction
Ipsum lorem, ipsum lorem

== Command: 1
Ipsum lorem, ipsum lorem
=== Description
Ipsum lorem, ipsum lorem
Ipsum lorem, ipsum lorem

== Command: 2
Ipsum lorem, ipsum lorem
=== Description
Ipsum lorem, ipsum lorem
Ipsum lorem, ipsum lorem

Code used to findBy with selector
        Map<Object, Object> selector = new HashMap<Object, Object>();
        selector.put("context", ":section");

        // Search about the sections within the document ==> Then we will get 5 sections 
        List<StructuralNode> findBy = node.findBy(selector);

        // Search about the section where text is starting with "Command" word
        for (int i = 0; i < findBy.size(); i++) {
            final StructuralNode subNode = findBy.get(i); 
            if (subNode.getTitle().startsWith("Command") {
            // HOW CAN I NOW GET THE SUBLEVEL 3 CONTAINING THE TEXT OF THE DESCRIPTION

Best

Charles
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard