Class: Saxon::XPath::StaticContext::DSL Private

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/saxon/xpath/static_context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Provides the hooks for constructing a Saxon::XPath::StaticContext with a DSL.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#args_hash, #initialize

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

Parameters:

  • block (Proc)

    a Proc/lambda (or to_proc‘d containing DSL calls

Returns:



96
97
98
99
100
# File 'lib/saxon/xpath/static_context.rb', line 96

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

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.

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.

Parameters:

  • collation_uri (String)

    The URI of the Collation to set as the default



108
109
110
# File 'lib/saxon/xpath/static_context.rb', line 108

def default_collation(collation_uri)
  @default_collation = collation_uri
end

#namespace(namespaces = {}) ⇒ Object

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.

Bind prefixes to namespace URIs

Parameters:

  • namespaces (Hash{String, Symbol => String}) (defaults to: {})


115
116
117
# File 'lib/saxon/xpath/static_context.rb', line 115

def namespace(namespaces = {})
  @declared_namespaces = @declared_namespaces.merge(namespaces.transform_keys(&:to_s)).freeze
end

#variable(qname, type = nil) ⇒ Object

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.

Declare a XPath variable’s existence in the context

explicit QName or prefix:name string form. The string form requires the namespace prefix to have already been declared with #namespace variable, either as a string using the same form as an XSLT as="" type definition, or as a hash of one key/value where that key is a Symbol taken from OccurenceIndicator and the value is either a Class that ItemType can convert to its XDM equivalent (e.g. String), or a string that ItemType can parse into an XDM type (e.g. xs:string</tthat {Saxon::ItemType} can parse into an XDM type (e.g. <tt>xs:string or element()). If it’s nil, then the default item()* – anything – type declaration is used

Parameters:

  • qname (String, Saxon::QName)

    The name of the variable as

  • type (String, Hash{Symbol => String, Class}, null) (defaults to: nil)

    The type of the



134
135
136
137
138
139
# File 'lib/saxon/xpath/static_context.rb', line 134

def variable(qname, type = nil)
  qname = resolve_variable_qname(qname)
  @declared_variables = @declared_variables.merge({
    qname => resolve_variable_declaration(qname, type)
  }).freeze
end