saxon-rb 0.5.0-java → 0.7.3-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,97 @@
1
+ require_relative '../serializer'
2
+ require_relative '../xdm/value'
3
+
4
+
5
+ module Saxon
6
+ module XSLT
7
+ # Represents the invocation of a compiled and loaded transformation,
8
+ # providing an idiomatic way to send the result a transformation to a
9
+ # particular Destination, or to serialize it directly to a file, string, or
10
+ # IO.
11
+ class Invocation
12
+ attr_reader :s9_transformer, :invocation_lambda
13
+ private :s9_transformer, :invocation_lambda
14
+
15
+ # @api private
16
+ def initialize(s9_transformer, invocation_lambda, raw)
17
+ @s9_transformer, @invocation_lambda, @raw = s9_transformer, invocation_lambda, raw
18
+ end
19
+
20
+ # Serialize the result to a string using the options specified in
21
+ # +<xsl:output/>+ in the XSLT
22
+ #
23
+ # @return [String] the serialized result of the transformation
24
+ def to_s
25
+ serializer_destination.serialize
26
+ end
27
+
28
+ # Serialize the result of the transformation. When called with a
29
+ # block, the block will be executed via instance-exec so that output
30
+ # properties can be set, e.g.
31
+ #
32
+ # result.serialize {
33
+ # output_property[:indent] = 'yes'
34
+ # }
35
+ #
36
+ # @overload serialize(io)
37
+ # Serialize the transformation to an IO
38
+ # @param [File, IO] io The IO to serialize to
39
+ # @return [nil]
40
+ # @yield the passed block bound via instance-exec to the new serializer
41
+ # @overload serialize(path)
42
+ # Serialize the transformation to file <tt>path</tt>
43
+ # @param [String, Pathname] path The path of the file to serialize to
44
+ # @return [nil]
45
+ # @yield the passed block bound via instance-exec to the new serializer
46
+ # @overload serialize
47
+ # Serialize the transformation to a String
48
+ # @return [String] The serialized XdmValue
49
+ def serialize(path_or_io = nil, &block)
50
+ serializer_destination(&block).serialize(path_or_io)
51
+ end
52
+
53
+ # Return the result of the transformation as an XDM Value, either as it is
54
+ # returned (if the XSLT::Executable was created with :raw => true), or
55
+ # wrapped in a Document node and sequence normalized.
56
+ #
57
+ # @return [Saxon::XDM::Value] the XDM value returned by the transformation
58
+ def xdm_value
59
+ if raw?
60
+ XDM.Value(invocation_lambda.call(nil))
61
+ else
62
+ invocation_lambda.call(s9_xdm_destination)
63
+ XDM.Value(s9_xdm_destination.getXdmNode)
64
+ end
65
+ end
66
+
67
+ # Send the result of the transformation to the supplied Destination
68
+ #
69
+ # @param s9_destination [net.sf.saxon.s9api.Destination] the Saxon
70
+ # destination to use
71
+ # @return [nil]
72
+ def to_destination(s9_destination)
73
+ invocation_lambda.call(s9_destination)
74
+ nil
75
+ end
76
+
77
+ # Whether the transformation was invoked as a 'raw' transformation, where
78
+ # an XDM Value result will be returned without being wrapped in a Document
79
+ # node, and without sequence normalization.
80
+ #
81
+ # @return [Boolean] whether the transformation was invoked 'raw' or not
82
+ def raw?
83
+ @raw
84
+ end
85
+
86
+ private
87
+
88
+ def serializer_destination(&block)
89
+ Saxon::Serializer::Destination.new(s9_transformer.newSerializer, invocation_lambda, &block)
90
+ end
91
+
92
+ def s9_xdm_destination
93
+ @s9_xdm_destination ||= Saxon::S9API::XdmDestination.new
94
+ end
95
+ end
96
+ end
97
+ end
@@ -5,7 +5,7 @@ require 'saxon/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'saxon-rb'
8
- spec.version = Saxon::VERSION
8
+ spec.version = Saxon::Version::WRAPPER
9
9
  spec.authors = ['Matt Patterson']
10
10
  spec.email = ['matt@werkstatt.io']
11
11
 
@@ -34,6 +34,6 @@ It aims to provide an idiomatic Ruby wrapper around all of Saxon's features.}
34
34
  spec.add_development_dependency 'addressable', '~> 2.4.0'
35
35
  spec.add_development_dependency 'webmock', '~> 2.3.2'
36
36
  spec.add_development_dependency 'yard', '~> 0.9.12'
37
- spec.add_development_dependency 'simplecov', '~> 0.15'
37
+ spec.add_development_dependency 'simplecov', '~> 0.17.1'
38
38
  spec.add_development_dependency 'rspec_junit_formatter'
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saxon-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.3
5
5
  platform: java
6
6
  authors:
7
7
  - Matt Patterson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-02 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ dependencies:
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '0.15'
130
+ version: 0.17.1
131
131
  name: simplecov
132
132
  prerelease: false
133
133
  type: :development
@@ -135,7 +135,7 @@ dependencies:
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.15'
138
+ version: 0.17.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
@@ -163,7 +163,9 @@ files:
163
163
  - ".circleci/config.yml"
164
164
  - ".gitignore"
165
165
  - ".rspec"
166
+ - ".rspec-jar-loading"
166
167
  - ".ruby-version"
168
+ - ".yardopts"
167
169
  - CODE_OF_CONDUCT.md
168
170
  - Gemfile
169
171
  - LICENSE.txt
@@ -171,6 +173,7 @@ files:
171
173
  - Rakefile
172
174
  - bin/console
173
175
  - bin/setup
176
+ - docs/templates/plugin.rb
174
177
  - lib/net/sf/saxon/Saxon-HE/9.9.1-6/Saxon-HE-9.9.1-6.jar
175
178
  - lib/saxon-rb.rb
176
179
  - lib/saxon-rb_jars.rb
@@ -178,6 +181,10 @@ files:
178
181
  - lib/saxon/axis_iterator.rb
179
182
  - lib/saxon/configuration.rb
180
183
  - lib/saxon/document_builder.rb
184
+ - lib/saxon/feature_flags.rb
185
+ - lib/saxon/feature_flags/errors.rb
186
+ - lib/saxon/feature_flags/helpers.rb
187
+ - lib/saxon/feature_flags/version.rb
181
188
  - lib/saxon/item_type.rb
182
189
  - lib/saxon/item_type/lexical_string_conversion.rb
183
190
  - lib/saxon/item_type/value_to_ruby.rb
@@ -191,8 +198,12 @@ files:
191
198
  - lib/saxon/s9api.rb
192
199
  - lib/saxon/sequence_type.rb
193
200
  - lib/saxon/serializer.rb
201
+ - lib/saxon/serializer/destination.rb
202
+ - lib/saxon/serializer/object.rb
203
+ - lib/saxon/serializer/output_properties.rb
194
204
  - lib/saxon/source.rb
195
205
  - lib/saxon/version.rb
206
+ - lib/saxon/version/library.rb
196
207
  - lib/saxon/xdm.rb
197
208
  - lib/saxon/xdm/array.rb
198
209
  - lib/saxon/xdm/atomic_value.rb
@@ -213,6 +224,7 @@ files:
213
224
  - lib/saxon/xslt/compiler.rb
214
225
  - lib/saxon/xslt/evaluation_context.rb
215
226
  - lib/saxon/xslt/executable.rb
227
+ - lib/saxon/xslt/invocation.rb
216
228
  - saxon-rb.gemspec
217
229
  homepage: https://github.com/fidothe/saxon-rb
218
230
  licenses:
@@ -234,8 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
246
  version: '0'
235
247
  requirements:
236
248
  - jar net.sf.saxon, Saxon-HE, 9.9.1-6
237
- rubyforge_project:
238
- rubygems_version: 2.7.10
249
+ rubygems_version: 3.1.3
239
250
  signing_key:
240
251
  specification_version: 4
241
252
  summary: Saxon 9.9 for JRuby, with an idiomatic Ruby API