METHODS

Access to nodes ordering

Return the closest following node (according to the ordering attribute) or undef if $node is the last one in the tree.

my $preceding_node = $node->get_prev_node();

Return the closest preceding node (according to the ordering attribute) or undef if $node is the first one in the tree.

Reordering nodes

Next four methods for changing the order of nodes (the word order defined by the attribute ord) have an optional argument $arg_ref for specifying switches. So far there is only one switch - without_children which is by default set to 0. It means that the default behavior is to shift the node with all its descendants. Only if you want to leave the position of the descendants unchanged and shift just the node, use e.g.

$node->shift_after_node($reference_node, {without_children=>1});

Shifting involves only changing the ordering attribute (ord) of nodes. There is no rehanging (changing parents). The node which is going to be shifted must be already added to the tree and the reference node must be in the same tree.

For languages with left-to-right script: after means "to the right of" and before means "to the left of".

$node->shift_after_node($reference_node);

Shifts (changes the ord of) the node just behind the reference node.

$node->shift_after_subtree($reference_node);

Shifts (changes the ord of) the node behind the subtree of the reference node.

$node->shift_before_node($reference_node);

Shifts (changes the ord of) the node just in front of the reference node.

$node->shift_before_subtree($reference_node);

Shifts (changes the ord of) the node in front of the subtree of the reference node.

Nonprojectivity

my $nonproj = $node->is_nonprojective();

Return 1 if the node is attached to its parent nonprojectively, i.e. there is at least one node between this node and its parent that is not descendant of the parent. Return 0 otherwise.