Class: Gammo::XPath::AST::Axis::Attribute

Inherits:
Gammo::XPath::AST::Axis
  • Object
show all
Defined in:
lib/gammo/xpath/ast/axis.rb

Constant Summary

Constants included from Subclassify

Subclassify::NotFoundError

Instance Method Summary collapse

Instance Method Details

#strain(context, context_node, node_set) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/gammo/xpath/ast/axis.rb', line 74

def strain(context, context_node, node_set)
  if node_test.instance_of?(NodeTest::Name) && node_test.local != ?*
    attribute =
      if !node_test.namespace
        context_node.get_attribute_node(node_test.local)
      else
        # TODO: Test this properly.
        context_node.get_attribute_node(node_test.local, namespace: node_test.namespace)
      end
    if attribute && attribute.namespace != 'http://www.w3.org/XML/1998/namespace'
      node_set << attribute if node_test.match?(attribute)
    end
    return
  end

  node_set.concat(context_node.attributes.select { |attribute|
    node_test.match?(attribute)
  })
end