Class: Saxon::AxisIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/saxon/axis_iterator.rb

Overview

An iterator across an XPath axis of an XDM document, e.g. down to children (child), up to the root (ancestor)

Examples:

iterate over child nodes

AxisIterator.new(node, :child).each do |child_node|
  puts child_node.node_name
end

Instance Method Summary collapse

Constructor Details

#initialize(xdm_node, axis) ⇒ AxisIterator

Returns a new instance of AxisIterator.



16
17
18
19
# File 'lib/saxon/axis_iterator.rb', line 16

def initialize(xdm_node, axis)
  @s9_xdm_node = xdm_node.to_java
  @s9_axis = Saxon::S9API::Axis.const_get(axis.to_s.upcase.to_sym)
end

Instance Method Details

#each {|the| ... } ⇒ Object

yields each node in the sequence

Yield Parameters:



28
29
30
# File 'lib/saxon/axis_iterator.rb', line 28

def each(&block)
  s9_sequence_iterator.lazy.map { |s9_xdm_node| Saxon::XDM::Node.new(s9_xdm_node) }.each(&block)
end

#to_javaSaxon::S9API::XdmSequenceIterator

Returns A new Saxon Java XDM sequence iterator.

Returns:

  • (Saxon::S9API::XdmSequenceIterator)

    A new Saxon Java XDM sequence iterator.



22
23
24
# File 'lib/saxon/axis_iterator.rb', line 22

def to_java
  s9_sequence_iterator
end