Sha256: fb158520afe5d9c05f40ef05541ded0fccf7d7edc13129ccd072a8dd9c7f2db0

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

require_relative 's9api'

module Saxon
  # An XPath Data Model Node object, representing an XML document, or an element or one of the other node chunks in the XDM.
  class AxisIterator
    include Enumerable

    attr_reader :s9_xdm_node, :s9_axis
    private :s9_xdm_node, :s9_axis

    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

    # @return [Saxon::S9API::XdmSequenceIterator] A new Saxon Java XDM sequence iterator.
    def to_java
      s9_sequence_iterator
    end

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

    private

    def s9_sequence_iterator
      s9_xdm_node.axisIterator(s9_axis)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saxon-rb-0.4.0-java lib/saxon/axis_iterator.rb