NAME

XML::XMetaL::Utilities::Iterator - Iterator class for XMetaL DOM nodes

SYNOPSIS

use XML::XMetaL::Utilities::Iterator;
use XML::XMetaL::Utilities::Filter::Element;

my $dom_node = $xmetal->{ActiveDocument}->{documentElement};
my $filter = XML::XMetaL::Utilities::Filter::Element->new();

my $iterator = XML::XMetaL::Utilities::Iterator->new(-domnode => $dom_node,
                                                     -filter  => $filter);
while ($iterator->has_next()) {
   $element_node = $iterator->next();
   # Do something with the element node
};

DESCRIPTION

The XML::XMetaL::Utilities::Iterator class is an iterator for XMetaL DOM nodes.

The iterator uses a node filter to determine which nodes in a DOM node tree to iterate over. See XML::XMetaL::Utilities::Filter::Base for more information about node filters.

Constructor and initialization

use XML::XMetaL::Utilities::Iterator;
my $iterator = XML::XMetaL::Utilities::Iterator->new(-domnode => $dom_node,
                                                     -filter  => $filter);

The constructor takes the following named parameters:

-domnode

The -domnode parameter must be an XMetaL DOM node.

-filter

The -filter parameter must be a filter object. The filter object should be a subclass of XML::XMetaL::Utilities::Filter::Base.

Class Methods

None.

Public Methods

has_next
while ($iterator->has_next()) {
   ...
};

The has_next method checks if there are more nodes to be stepped through by the iterator.

The method returns a true value if there are more nodes to iterate over, false if there are not.

Note that in many cases, you can dispense with the has_next method and just do this:

my $current_node;
while ($current_node = $iterator->next()) {
   ...
};
next
my $current_node = $iterator->next();

The next method returns the next node to iterate over. If there are no more nodes, the method returns undef.

Private Methods

None.

ENVIRONMENT

The Corel XMetaL XML editor must be installed.

BUGS

A lot, I am sure.

Please send bug reports to <henrik.martensson@bostream.nu>.

SEE ALSO

See XML::XMetaL, XML::XMetaL::Filter::Base.

AUTHOR

Henrik Martensson, <henrik.martensson@bostream.nu>

COPYRIGHT AND LICENSE

Copyright 2003 by Henrik Martensson

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.