Class: Saxon::Processor
- Inherits:
-
Object
- Object
- Saxon::Processor
- 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
- .create(config = nil) ⇒ Saxon::Processor
-
.default ⇒ Saxon::Processor
Provides a processor with default configuration.
Instance Method Summary collapse
-
#==(other) ⇒ Object
compare equal if the underlying java processor is the same instance for self and other.
-
#config ⇒ Saxon::Configuration
This processor’s configuration instance.
-
#initialize(s9_processor) ⇒ Processor
constructor
private
A new instance of Processor.
-
#to_java ⇒ net.sf.saxon.s9api.Processor
The underlying Saxon processor.
-
#XML(input, opts = {}) ⇒ Saxon::XML::Document
The new XML Document.
-
#XSLT(input, opts = {}) ⇒ Saxon::XSLT::Stylesheet
The new XSLT Stylesheet.
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 |
.default ⇒ Saxon::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 |
#config ⇒ Saxon::Configuration
Returns This processor’s configuration instance.
74 75 76 |
# File 'lib/saxon/processor.rb', line 74 def config @config ||= Saxon::Configuration.create(self) end |
#to_java ⇒ net.sf.saxon.s9api.Processor
Returns The underlying Saxon processor.
62 63 64 |
# File 'lib/saxon/processor.rb', line 62 def to_java @s9_processor end |
#XML(input, opts = {}) ⇒ Saxon::XML::Document
Returns the new 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
Returns the new XSLT Stylesheet.
50 51 52 |
# File 'lib/saxon/processor.rb', line 50 def XSLT(input, opts = {}) Saxon::XSLT::Stylesheet.parse(self, input, opts) end |