Class: Saxon::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/saxon/processor.rb

Overview

Saxon::Processor wraps the S9API::Processor object. This is the object responsible for creating an XSLT compiler or an XML Document object.

The Processor is threadsafe, and can be shared between threads. But, most importantly XSLT or XML objects created by a Processor can only be used with other XSLT or XML objects created by the same Processor instance.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(s9_processor) ⇒ Processor

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



43
44
45
# File 'lib/saxon/processor.rb', line 43

def initialize(s9_processor)
  @s9_processor = s9_processor
end

Class Method Details

.create(config = nil) ⇒ Saxon::Processor



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/saxon/processor.rb', line 26

def self.create(config = nil)
  Saxon::Loader.load!
  case config
  when nil
    licensed_or_config_source = false
  when Saxon::Configuration
    licensed_or_config_source = config.to_java
  else
    licensed_or_config_source = Saxon::SourceHelper.to_stream_source(config)
  end
  s9_processor = S9API::Processor.new(licensed_or_config_source)
  new(s9_processor)
end

.defaultSaxon::Processor

Provides a processor with default configuration. Essentially a singleton instance



18
19
20
# File 'lib/saxon/processor.rb', line 18

def self.default
  @processor ||= create(Saxon::Configuration.default)
end

Instance Method Details

#==(other) ⇒ Object

compare equal if the underlying java processor is the same instance for self and other



69
70
71
# File 'lib/saxon/processor.rb', line 69

def ==(other)
  other.to_java === to_java
end

#configSaxon::Configuration



74
75
76
# File 'lib/saxon/processor.rb', line 74

def config
  @config ||= Saxon::Configuration.create(self)
end

#to_javanet.sf.saxon.s9api.Processor



62
63
64
# File 'lib/saxon/processor.rb', line 62

def to_java
  @s9_processor
end

#XML(input, opts = {}) ⇒ Saxon::XML::Document



57
58
59
# File 'lib/saxon/processor.rb', line 57

def XML(input, opts = {})
  Saxon::XML::Document.parse(self, input, opts)
end

#XSLT(input, opts = {}) ⇒ Saxon::XSLT::Stylesheet



50
51
52
# File 'lib/saxon/processor.rb', line 50

def XSLT(input, opts = {})
  Saxon::XSLT::Stylesheet.parse(self, input, opts)
end