Class: Saxon::XdmNode

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

Overview

An XPath Data Model Node object, representing an XML document, or an element or one of the other node chunks in the XDM.

Instance Method Summary collapse

Constructor Details

#initialize(s9_xdm_node) ⇒ XdmNode

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of XdmNode.



12
13
14
# File 'lib/saxon/xdm_node.rb', line 12

def initialize(s9_xdm_node)
  @s9_xdm_node = s9_xdm_node
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



46
47
48
49
# File 'lib/saxon/xdm_node.rb', line 46

def ==(other)
  return false unless other.is_a?(XdmNode)
  s9_xdm_node.equals(other.to_java)
end

#axis_iterator(axis) ⇒ Object



61
62
63
# File 'lib/saxon/xdm_node.rb', line 61

def axis_iterator(axis)
  AxisIterator.new(self, axis)
end

#each(&block) ⇒ Object



57
58
59
# File 'lib/saxon/xdm_node.rb', line 57

def each(&block)
  axis_iterator(:child).each(&block)
end

#hashObject



53
54
55
# File 'lib/saxon/xdm_node.rb', line 53

def hash
  @hash ||= s9_xdm_node.hashCode
end

#node_kindObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/saxon/xdm_node.rb', line 27

def node_kind
  @node_kind ||= case s9_xdm_node.nodeKind
  when Saxon::S9API::XdmNodeKind::ELEMENT
    :element
  when Saxon::S9API::XdmNodeKind::TEXT
    :text
  when Saxon::S9API::XdmNodeKind::ATTRIBUTE
    :attribute
  when Saxon::S9API::XdmNodeKind::NAMESPACE
    :namespace
  when Saxon::S9API::XdmNodeKind::COMMENT
    :comment
  when Saxon::S9API::XdmNodeKind::PROCESSING_INSTRUCTION
    :processing_instruction
  when Saxon::S9API::XdmNodeKind::DOCUMENT
    :document
  end
end

#node_nameObject



21
22
23
24
25
# File 'lib/saxon/xdm_node.rb', line 21

def node_name
  return @node_name if instance_variable_defined?(:@node_name)
  node_name = s9_xdm_node.getNodeName
  @node_name = node_name.nil? ? nil : Saxon::QName.new(node_name)
end

#to_javaSaxon::S9API::XdmNode

Returns The underlying Saxon Java XDM node object.

Returns:

  • (Saxon::S9API::XdmNode)

    The underlying Saxon Java XDM node object.



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

def to_java
  @s9_xdm_node
end