17.4 Element Counters in Files

The position of the output unit being formatted in its file or the total number of elements output to a file is interesting for navigation header and footer formatting, for instance to format end of files, decide which type navigation header or footer is needed and whether a rule should be output.

To get information on tree elements unit counter in files, use count_elements_in_filename:

Function: $count = $converter->count_elements_in_filename ($specification, $file_name)

Return output unit counter for $file_name, or undef if the counter does not exist. The counter returned depends on $specification:

current

Return the number of output units associated with $file_name having already been processed.

remaining

Return the number of output units associated with $file_name that remains to be processed.

total

Return the total number of output units associated with the file.

For example, to get the total number of output units associated with the file of a node element:

my $file_name = $converter->command_filename($node_element);
my $number = $converter->count_elements_in_filename('total',
                                                  $file_name);