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.

Parameters:

  • s9_xpath_executable (net.sf.saxon.s9api.XPathExecutable)

    the Saxon compiled XPath object

  • static_context (XPath::StaticContext)

    the XPath’s static context



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

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)

Returns the XPath’s static context.

Returns:



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

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.

Parameters:

Returns:



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

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::XdmAtomicValue.create(value).to_java)
  end
  Result.new(selector.iterator)
end

#to_javanet.sf.saxon.s9api.XPathExecutable

Returns the underlying Saxon XPathExecutable.

Returns:

  • (net.sf.saxon.s9api.XPathExecutable)

    the underlying Saxon XPathExecutable



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

def to_java
  @s9_xpath_executable
end