Class: Saxon::XPath::StaticContext::DSL
- Inherits:
-
Object
- Object
- Saxon::XPath::StaticContext::DSL
- Includes:
- Common
- Defined in:
- lib/saxon/xpath/static_context.rb
Overview
Provides the hooks for constructing a Saxon::XPath::StaticContext with a DSL.
Class Method Summary collapse
-
.define(block, args = {}) ⇒ Saxon::XPath::StaticContext
private
Create an instance based on the args hash, and execute the passed in Proc/lambda against it using
#instance_exec
and return a new Saxon::XPath::StaticContext with the results.
Instance Method Summary collapse
-
#default_collation(collation_uri) ⇒ Object
Set the default Collation to use.
-
#namespace(namespaces = {}) ⇒ Object
Bind prefixes to namespace URIs.
-
#variable(qname, sequence_type = nil) ⇒ Object
Declare a XPath variable’s existence in the context.
Methods included from Common
Class Method Details
.define(block, args = {}) ⇒ Saxon::XPath::StaticContext
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.
Create an instance based on the args hash, and execute the passed in Proc/lambda against it using #instance_exec
and return a new Saxon::XPath::StaticContext with the results
57 58 59 60 61 |
# File 'lib/saxon/xpath/static_context.rb', line 57 def self.define(block, args = {}) dsl = new(args) dsl.instance_exec(&block) unless block.nil? StaticContext.new(dsl.args_hash) end |
Instance Method Details
#default_collation(collation_uri) ⇒ Object
Set the default Collation to use. This should be one of the special collation URIs Saxon recognises, or one that has been registered using Saxon::Processor#declare_collations on the Processor that created the Compiler this context is for.
69 70 71 |
# File 'lib/saxon/xpath/static_context.rb', line 69 def default_collation(collation_uri) @default_collation = collation_uri end |
#namespace(namespaces = {}) ⇒ Object
Bind prefixes to namespace URIs
76 77 78 |
# File 'lib/saxon/xpath/static_context.rb', line 76 def namespace(namespaces = {}) @declared_namespaces = @declared_namespaces.merge(namespaces.map { |k, v| [k.to_s, v] }.to_h).freeze end |
#variable(qname, sequence_type = nil) ⇒ Object
Declare a XPath variable’s existence in the context
90 91 92 93 94 95 |
# File 'lib/saxon/xpath/static_context.rb', line 90 def variable(qname, sequence_type = nil) qname = resolve_variable_qname(qname) @declared_variables = @declared_variables.merge({ qname => resolve_variable_declaration(qname, sequence_type) }).freeze end |