Class: Saxon::XSLT::Compiler

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/saxon/xslt/compiler.rb

Overview

Compiles XSLT stylesheets so they can be executed

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s9_processor, evaluation_context) ⇒ Compiler

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

Parameters:

  • s9_processor (net.sf.saxon.s9api.Processor)

    the Saxon Processor to wrap

  • evaluation_context (Saxon::XSLT::EvaluationContext)

    the static context XPaths compiled using this compiler will have



31
32
33
# File 'lib/saxon/xslt/compiler.rb', line 31

def initialize(s9_processor, evaluation_context)
  @s9_processor, @evaluation_context = s9_processor, evaluation_context
end

Instance Attribute Details

#declared_collationsHash<String => java.text.Collator> (readonly)

Returns declared collations as URI => Collator hash.

Returns:

  • (Hash<String => java.text.Collator>)

    declared collations as URI => Collator hash



# File 'lib/saxon/xslt/compiler.rb', line 36

#default_collationString (readonly)

Returns the URI of the default declared collation.

Returns:

  • (String)

    the URI of the default declared collation



# File 'lib/saxon/xslt/compiler.rb', line 36

#static_parametersHash<Saxon::QName => Saxon::XdmValue, Saxon::XdmNode, (readonly)

Saxon::XdmAtomicValue>] parameters required at compile time as QName => value hash

Returns:



# File 'lib/saxon/xslt/compiler.rb', line 36

Class Method Details

.create(processor) { ... } ⇒ Saxon::XSLT::Compiler

Create a new XSLT::Compiler using the supplied Processor. Passing a block gives access to a DSL for setting up the compiler’s static context.

Parameters:

Yields:

  • An XSLT compiler DSL block

Returns:



16
17
18
19
# File 'lib/saxon/xslt/compiler.rb', line 16

def self.create(processor, &block)
  evaluation_context = XSLT::EvaluationContext.define(block)
  new(processor.to_java, evaluation_context)
end

Instance Method Details

#compile(source, &block) ⇒ Saxon::XSLT::Executable

Returns the executable stylesheet.

Parameters:

Returns:



46
47
48
49
50
51
# File 'lib/saxon/xslt/compiler.rb', line 46

def compile(source, &block)
  Saxon::XSLT::Executable.new(
    new_compiler.compile(source.to_java),
    evaluation_context.define(block)
  )
end

#create(&block) ⇒ Object



53
54
55
56
# File 'lib/saxon/xslt/compiler.rb', line 53

def create(&block)
  new_evaluation_context = evaluation_context.define(block)
  self.class.new(@s9_processor, new_evaluation_context)
end