Class: Saxon::XPath::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/saxon/xpath/executable.rb

Overview

Represents a compiled XPath query ready to be executed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s9_xpath_executable, static_context) ⇒ Executable

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 Executable.



15
16
17
# File 'lib/saxon/xpath/executable.rb', line 15

def initialize(s9_xpath_executable, static_context)
  @s9_xpath_executable, @static_context = s9_xpath_executable, static_context
end

Instance Attribute Details

#static_contextXPath::StaticContext (readonly)



8
9
10
# File 'lib/saxon/xpath/executable.rb', line 8

def static_context
  @static_context
end

Instance Method Details

#run(context_item, variables = {}) ⇒ Saxon::XPath::Result

Run the compiled query using a passed-in node as the context item.



23
24
25
26
27
28
29
30
# File 'lib/saxon/xpath/executable.rb', line 23

def run(context_item, variables = {})
  selector = to_java.load
  selector.setContextItem(context_item.to_java)
  variables.each do |qname_or_string, value|
    selector.setVariable(static_context.resolve_variable_qname(qname_or_string).to_java, Saxon::XDM.Value(value).to_java)
  end
  Result.new(selector.iterator)
end

#to_javanet.sf.saxon.s9api.XPathExecutable



34
35
36
# File 'lib/saxon/xpath/executable.rb', line 34

def to_java
  @s9_xpath_executable
end