Class: Saxon::XPath::Executable
- Inherits:
-
Object
- Object
- Saxon::XPath::Executable
- Defined in:
- lib/saxon/xpath/executable.rb
Overview
Represents a compiled XPath query ready to be executed
Instance Attribute Summary collapse
-
#static_context ⇒ XPath::StaticContext
readonly
The XPath’s static context.
Instance Method Summary collapse
-
#initialize(s9_xpath_executable, static_context) ⇒ Executable
constructor
private
A new instance of Executable.
-
#run(context_item, variables = {}) ⇒ Saxon::XPath::Result
Run the compiled query using a passed-in node as the context item.
-
#to_java ⇒ net.sf.saxon.s9api.XPathExecutable
The underlying Saxon
XPathExecutable.
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.
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_context ⇒ XPath::StaticContext (readonly)
Returns the XPath’s static context.
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.
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_java ⇒ net.sf.saxon.s9api.XPathExecutable
Returns the underlying Saxon XPathExecutable.
35 36 37 |
# File 'lib/saxon/xpath/executable.rb', line 35 def to_java @s9_xpath_executable end |