rexslt 0.6.12 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rexslt.rb +211 -152
  4. data.tar.gz.sig +0 -0
  5. metadata +35 -35
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8677062cfbfef49a97de56c7fb501abf1f57c48bbea804ec13d4a6dcb93d69ed
4
- data.tar.gz: dab58fa40b0365bef22573ec58c7b97cf86a5c4fdeddbd103395b2655a887e02
3
+ metadata.gz: 725f7f09d8f7723708b9d830560c57c355f4e9b4477b5b0175b788a1f4d23577
4
+ data.tar.gz: 60662b52e4e3a423da34faf3b95f7f327ddc6b3732a4335a4601baa7da02a0eb
5
5
  SHA512:
6
- metadata.gz: f94cb4e9621cda90f7e4e785fd7b45d53b94734bc3e3f01b8713a45faad7f9fdaaf5cefb478917abad1ff4c3533e40bfc963061b2436c401de011d6a5676841f
7
- data.tar.gz: 6fbef82369e5534e05928a13b7f3ff01562767d65bded4e32bc8fbba26754271e7d5f1abd1d32c7a79df252e70705d91760a3863f91bcf76a8acf9add5a8cdf4
6
+ metadata.gz: cdc0706519a8ef26fed3262a66b5166b88cc7b13543f85038e9f09009f504c69b3d3a9e4dc99fa4a6dad9025ef34cca760cd1c3ccee219602bcc1c7b79803104
7
+ data.tar.gz: a767396429dcea36fedb2f19cf04523be1a6d9df614f6b415da1851a361555fd80e19d9fcab8be284513be53a21cd229babd0e915f1fb0c090e19d7651a5eeff
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rexslt.rb CHANGED
@@ -3,38 +3,40 @@
3
3
  # file: rexslt.rb
4
4
 
5
5
  require 'rexle'
6
- require 'rxfhelper'
6
+ require 'rxfreader'
7
7
  require 'logger'
8
8
 
9
9
 
10
10
  # modifications:
11
11
  #
12
- # 01-Feb-2019: bug fix: new line characters are no longer stripped
12
+ # 22-Feb-2022: minor improvement: Replaced RXFHelper with RXFReader.
13
+ # 01-Feb-2019: bug fix: new line characters are no longer stripped
13
14
  # between XSL elements
15
+ # bug fix: An attribute variable value is now returned correctly
14
16
  # 19-Jan-2018: feature: Implemented Rexslt#to_xml which returns pretty XML
15
- # 16-Sep-2017: improvement: all predicates in an xsl:choose
17
+ # 16-Sep-2017: improvement: all predicates in an xsl:choose
16
18
  # condition now must be true
17
19
  # 15-Sep-2017: feature: Implemented xsl_call_template
18
- # 21-May-2016: bug fix: An update to the Rexle gem regarding the new
19
- # Rexle::Element::Attribute datatype caused the sort_by code
20
+ # 21-May-2016: bug fix: An update to the Rexle gem regarding the new
21
+ # Rexle::Element::Attribute datatype caused the sort_by code
20
22
  # to break. This has now been rectified.
21
- # 04-May-2016: bug fix: disabled the method which strips out all new
22
- # line spaces, and replaced it with a statement in the
23
- # read_raw_text() method which strips out space before and
23
+ # 04-May-2016: bug fix: disabled the method which strips out all new
24
+ # line spaces, and replaced it with a statement in the
25
+ # read_raw_text() method which strips out space before and
24
26
  # after the text
25
- # 03-May-2016: A returned HTML document will no longer include an
27
+ # 03-May-2016: A returned HTML document will no longer include an
26
28
  # XML declaration by default
27
- # 30-Apr-2016: bug fix: This class can now be executed within an
29
+ # 30-Apr-2016: bug fix: This class can now be executed within an
28
30
  # eval statement which runs within another class
29
- # 24-Apr-2016: The position() function is now supported within an
31
+ # 24-Apr-2016: The position() function is now supported within an
30
32
  # xsl:value-of select attribute
31
- # An xsl:attribute value can now be rendered using
33
+ # An xsl:attribute value can now be rendered using
32
34
  # an xsl:text element
33
35
 
34
36
  module RexPath
35
-
37
+
36
38
  refine Rexle::Element do
37
-
39
+
38
40
  def to_xpath(option=nil)
39
41
  def attribute_scan(node)
40
42
  result = ''
@@ -62,38 +64,38 @@ end
62
64
  class Rexslt
63
65
  using RexPath
64
66
  using ColouredText
65
-
66
- def initialize(xsl, xml, raw_params={}, debug: false)
67
-
67
+
68
+ def initialize(xsl, xml, raw_params={}, debug: false)
69
+
68
70
  ## debugging variables
69
-
71
+
70
72
  @rn = 0
71
73
  @rre = 0
72
74
 
73
75
  super()
74
76
  puts 'before options'.info if @debug
75
77
  @options = {}
76
-
78
+
77
79
  params = raw_params.merge({debug: false})
78
80
  @debug = debug
79
- custom_params = params.inject({}){|r,x| r.merge(Hash[x[0].to_s,x[1]])}
81
+ custom_params = params.inject({}){|r,x| r.merge(Hash[x[0].to_s,x[1]])}
80
82
  puts 'before xsl_transform'.info if @debug
81
83
 
82
- xslt_transform(*[xsl, xml].map{|x| RXFHelper.read(x).first}, custom_params)
84
+ xslt_transform(*[xsl, xml].map{|x| RXFReader.read(x).first}, custom_params)
83
85
  end
84
-
86
+
85
87
  def to_s(options={})
86
88
  @doc.to_s(@options.merge(options)).sub(/<root4>/,'').sub(/<\/root4>$/m,'').lstrip
87
89
  end
88
-
90
+
89
91
  def to_doc(); @doc; end
90
-
92
+
91
93
  def to_xml()
92
- @doc.root.xml(pretty: true).sub(/<root3>\n/,'').sub(/<\/root3>$/m,'')
94
+ @doc.root.xml(pretty: true).sub(/<root4>/,'').sub(/<\/root4>$/m,'')
93
95
  end
94
96
 
95
97
  private
96
-
98
+
97
99
  def filter_out_spaces(e)
98
100
 
99
101
  e.children.each do |x|
@@ -106,10 +108,10 @@ class Rexslt
106
108
  elsif x.is_a? Rexle::Element and x.children.length > 0 then
107
109
  filter_out_spaces x
108
110
  end
109
-
111
+
110
112
  end
111
113
  end
112
-
114
+
113
115
 
114
116
  def xsl_apply_templates(element, x, doc_element, indent, i)
115
117
 
@@ -119,11 +121,11 @@ class Rexslt
119
121
 
120
122
  keypath = node.to_xpath :no_cond
121
123
  matched_node = nil
122
-
124
+
123
125
  # check for a nest <xsl:sort element
124
-
126
+
125
127
  sort = x.element('xsl:sort')
126
-
128
+
127
129
  if sort then
128
130
 
129
131
  orderx = sort.attributes[:order] || 'ascending'
@@ -150,50 +152,50 @@ class Rexslt
150
152
  end
151
153
 
152
154
  if matched_node then
153
-
155
+
154
156
  template_xpath, template = raw_template
155
-
157
+
156
158
  if sort_field then
157
-
158
- sort_order = lambda do |x|
159
-
160
- r = x.element(sort_field);
161
159
 
162
- if r.respond_to?(:value) then
160
+ sort_order = lambda do |x|
161
+
162
+ r = x.element(sort_field);
163
+
164
+ if r.respond_to?(:value) then
163
165
  r.value
164
166
  else
165
167
  data_type == 'text' ? r : r.to_i
166
168
  end
167
169
  end
168
170
 
169
- a = matched_node.sort_by(&sort_order).each_with_index do |child_node,i|
171
+ a = matched_node.sort_by(&sort_order).each_with_index do |child_node,i|
170
172
  read_node template, child_node, doc_element, indent, i+1
171
173
  end
172
174
  a.reverse! if orderx == 'descending'
173
175
  else
174
- r = matched_node.each_with_index do |child_node,i|
176
+ r = matched_node.each_with_index do |child_node,i|
175
177
  read_node template, child_node, doc_element, indent, i+1
176
- end
178
+ end
177
179
  return r
178
180
  end
179
181
  end
180
182
 
181
183
  end
182
-
184
+
183
185
  def match?(raw_keypath, raw_path)
184
186
  return false if raw_path == ['*']
185
- keypath = raw_keypath.split('/').reverse.take raw_path.length
187
+ keypath = raw_keypath.split('/').reverse.take raw_path.length
186
188
  path = raw_path.reverse
187
189
  r = path.map.with_index.select{|x,i|x == '*'}.map(&:last)
188
190
 
189
- r.each do |n|
191
+ r.each do |n|
190
192
  # get the relative value from path
191
193
  path[n] = keypath[n]
192
- end
193
-
194
- keypath == path
194
+ end
195
+
196
+ keypath == path
195
197
  end
196
-
198
+
197
199
  def position()
198
200
  @position ||= 0
199
201
  end
@@ -213,39 +215,57 @@ class Rexslt
213
215
 
214
216
  doc_element.add_attribute(name, value)
215
217
  end
216
-
218
+
217
219
  def xsl_call_template(element, x, doc_element, indent, i)
218
-
220
+
219
221
  name = x.attributes[:name]
220
222
  template = @doc_xsl.root.element("xsl:template[@name='#{name}']")
221
-
223
+
222
224
  read_node template, element, doc_element, indent, i
223
225
  end
224
226
 
225
227
  def xsl_choose(element, x, doc_element, indent, i)
226
-
228
+
227
229
 
228
230
  r = x.xpath("xsl:when").map do |xsl_node|
229
231
 
230
232
  condition = xsl_node.attributes[:test]
231
233
 
232
- if element.xpath(condition).all? then
233
- read_raw_element(element, xsl_node.elements.first, doc_element, indent, i)
234
+ if element.xpath(condition).all? then
235
+ read_raw_element(element, xsl_node.elements.first, doc_element, indent, i)
234
236
  true
235
237
  else
236
238
  false
237
239
  end
238
240
  end
239
-
241
+
240
242
  unless r.any? then
241
243
  otherwise = x.element("xsl:otherwise")
242
244
  if otherwise then
243
245
  read_node(otherwise, element, doc_element, indent)
244
246
  end
245
- end
247
+ end
248
+
249
+ end
250
+
251
+ def xsl_cdata(element, x, doc_element, indent, i)
252
+ puts ('cdata x: ' + element.inspect) if @debug
253
+
254
+ new_element = Rexle::CData.new(x.value.to_s)
255
+
256
+ read_node(x, element, new_element, indent, i)
257
+ doc_element.add new_element
258
+ end
259
+
260
+ def xsl_comment(element, x, doc_element, indent, i)
261
+ #puts ('comment x: ' + element.inspect) if @debug
246
262
 
263
+ new_element = Rexle::Comment.new(x.value.to_s)
264
+
265
+ read_node(x, element, new_element, indent, i)
266
+ doc_element.add new_element
247
267
  end
248
-
268
+
249
269
  def xsl_copy_of(element, x, doc_element, indent, i)
250
270
  #jr251012 indent = 1 unless indent
251
271
  #jr251012 indent_element(element, x, doc_element, indent, indent - 1) do
@@ -256,35 +276,39 @@ class Rexslt
256
276
  #jr251012 end
257
277
 
258
278
  end
259
-
279
+
260
280
  def xsl_element(element, x, doc_element, indent, i)
261
-
281
+
262
282
  indent_before(element, x, doc_element, indent + 1, i) if @indent == true
263
283
 
264
284
  name = x.attributes[:name]
265
285
  variable = name[/^\{(.*)\}$/,1]
266
286
 
287
+ puts 'variable: ' + variable.inspect if @debug
288
+
267
289
  if variable then
268
290
  name = element.element(variable)
269
291
  end
270
292
 
271
293
  new_element = Rexle::Element.new(name) # .add_text(x.value.strip)
272
- new_element.text = element.text if element.text
294
+ puts 'element.text: ' + element.to_s.inspect if @debug
295
+ new_element.text = element.text.to_s.strip
273
296
 
274
297
  read_node(x, element, new_element, indent, i)
275
- doc_element.add new_element
298
+ doc_element.add new_element
276
299
  indent_after(element, x, doc_element, indent) if @indent == true
277
300
  end
278
-
301
+
279
302
  def xsl_for_each(element, x, doc_element, indent, i)
280
-
303
+
304
+ puts ('inside xsl_for_each x.children: ' + x.children.inspect).debug if @debug
281
305
  xpath = x.attributes[:select]
282
306
 
283
307
  nodes = element.xpath xpath
284
-
308
+
285
309
  # check for sort
286
310
  sort_node = x.element 'xsl:sort'
287
-
311
+
288
312
  if sort_node then
289
313
 
290
314
  sort_field = sort_node.attributes[:select]
@@ -306,33 +330,35 @@ class Rexslt
306
330
  end
307
331
 
308
332
  end
309
-
333
+
310
334
  field = raw_order[/^\{\$(.*)\}/,1]
311
335
  order = field ? @param[field] : raw_order
312
336
  nodes.reverse! if order.downcase == 'descending'
313
337
  end
314
-
338
+ puts ('nodes: ' + nodes.inspect).debug if @debug
315
339
  nodes.each.with_index {|node, j| read_node(x, node, doc_element, indent, j+1)}
316
-
340
+
317
341
  end
318
-
342
+
319
343
  def xsl_if(element, x, doc_element, indent, i=0)
320
344
 
321
345
  cond = x.attributes[:test].clone
322
-
346
+ puts ('cond: ' + cond.inspect).debug if @debug
347
+
323
348
  cond.sub!(/position\(\)/, i.to_s)
324
349
  cond.sub!(/&lt;/,'<')
325
350
  cond.sub!(/&gt;/,'>')
326
351
  cond.sub!(/\bmod\b/,'%')
352
+ cond.gsub!(/&apos;/,"'")
327
353
 
328
- result = element.element cond
354
+ result = element.element cond
329
355
 
330
356
  if result then
331
357
  read_node x, element, doc_element, indent, i
332
358
  end
333
359
 
334
360
  end
335
-
361
+
336
362
  # Ignores comment tags
337
363
  #
338
364
  def ignore(*args)
@@ -340,7 +366,7 @@ class Rexslt
340
366
 
341
367
  def indent_before(element, x, doc_element, indent, i)
342
368
  text = ''
343
- unless doc_element.texts.empty? and doc_element.texts.last.nil? then
369
+ unless doc_element.texts.empty? and doc_element.texts.last.nil? then
344
370
  if indent > 1 then
345
371
  text = "\n" + ' ' * (indent - 1) #unless doc_element.texts.last.to_s[/^\n\s/m]
346
372
  end
@@ -353,33 +379,36 @@ class Rexslt
353
379
 
354
380
  def indent_after(element, x, doc_element, prev_indent)
355
381
 
356
- if @indent == true then
357
- doc_element.add_text "\n" + ' ' * (prev_indent > 0 ? prev_indent - 1 : prev_indent)
358
- end
382
+ puts 'indent? : ' + @indent.inspect if @debug
383
+
384
+ if @indent == true then
385
+ doc_element.add_text ' ' * (prev_indent > 0 ? prev_indent - 1 : prev_indent)
386
+ end
359
387
  end
360
-
361
- def indent_element(element, x, doc_element, indent, previous_indent)
362
- indent_before(element, x, doc_element, indent, i) if @indent == true
388
+
389
+ def indent_element(element, x, doc_element, indent, previous_indent)
390
+ indent_before(element, x, doc_element, indent, i) if @indent == true
363
391
  yield
364
392
  indent_after(element, x, doc_element, previous_indent) if @indent == true
365
- end
393
+ end
366
394
 
367
- def padding(element,raw_indent, x)
395
+ def padding(element,raw_indent, x)
368
396
  # if there is any other elements in doc_element don't check for an indent!!!!
369
397
 
370
- indent = 0
371
- indent = raw_indent + 1 if element.texts.length <= 0
372
- x.to_s.strip.length > 0 ? ' ' * indent : ''
398
+ indent = 0
399
+ indent = raw_indent + 1 if element.texts.length <= 0
400
+ x.to_s.strip.length > 0 ? ' ' * indent : ''
373
401
  end
374
-
375
-
402
+
403
+
376
404
  # Reads an XSL node which is either an XSL element, a string or a comment
377
405
  # template_node: XSL node
378
406
  # element: XML node
379
407
  # doc_element: target document element
380
408
  #
381
409
  def read_node(template_node, element, doc_element, indent, i=0)
382
-
410
+
411
+ puts 'children: ' + template_node.children.inspect if @debug
383
412
  template_node.children.each_with_index do |x,j|
384
413
 
385
414
  puts ('x: ' + x.inspect).debug if @debug
@@ -389,8 +418,12 @@ class Rexslt
389
418
  else
390
419
  :ignore
391
420
  end
421
+ puts ('name: ' + name.inspect).debug if @debug
422
+
423
+ r2 = method(name).call(element, x, doc_element, indent, i)
424
+ puts 'r2b: ' + r2.inspect if @debug
425
+ r2
392
426
 
393
- method(name).call(element, x, doc_element, indent, i)
394
427
  end
395
428
 
396
429
  end
@@ -408,17 +441,18 @@ class Rexslt
408
441
  end
409
442
 
410
443
  end
411
-
444
+
412
445
  # element: xml element
413
446
  # x: xsl element
414
- # doc_element:
447
+ # doc_element:
415
448
  #
416
449
  def read_raw_element(element, x, doc_element, indent, j)
417
-
418
- method_name = x.name.gsub(/[:-]/,'_').to_sym
419
-
450
+
451
+ method_name = x.name.gsub(/[:-]/,'_').to_sym
452
+ puts ('method_name: ' + method_name.inspect).debug if @debug
453
+
420
454
  if @xsl_methods.include? method_name then
421
-
455
+
422
456
  if method_name == :'xsl_apply_templates' then
423
457
  #doc_element = doc_element.elements.last
424
458
  end
@@ -427,35 +461,43 @@ class Rexslt
427
461
 
428
462
  else
429
463
 
430
- previous_indent = indent
464
+ previous_indent = indent
431
465
  la = x.name
432
466
  new_indent = indent + 1 if @indent == true
433
467
 
434
468
  new_element = x.clone
435
469
 
436
- new_element.attributes.each do |k,raw_v|
437
-
470
+ new_element.attributes.each do |k,raw_v|
471
+
438
472
  v = raw_v.is_a?(Array) ? raw_v.join(' ') : raw_v
439
-
473
+
474
+ puts 'v: ' + v.inspect if @debug
475
+
440
476
  if v[/{/] then
441
477
 
442
478
  v.gsub!(/(\{[^\}]+\})/) do |x2|
443
479
 
444
480
  xpath = x2[/\{([^\}]+)\}/,1]
445
- text = element.text(xpath)
481
+ puts 'element.text(xpath): ' + element.text(xpath).inspect if @debug
482
+ text = element.text(xpath).to_s.strip
483
+ puts 'text: ' + text.inspect if @debug
446
484
  text ? text.clone : ''
447
-
485
+
448
486
  end
449
487
 
450
- end
451
- end
452
-
453
- if x.children.length > 0 then
488
+ puts '2. v: ' + v.inspect if @debug
489
+
490
+ end
491
+ end
492
+
493
+ puts 'x.children.length: ' + x.children.length.inspect if @debug
494
+
495
+ if x.children.length > 0 then
454
496
 
455
497
  indent_before(element, x, doc_element, new_indent, j) if @indent == true
456
-
457
- read_node(x, element, new_element, new_indent, j)
458
- doc_element.add new_element
498
+
499
+ read_node(x, element, new_element, new_indent, j)
500
+ doc_element.add new_element
459
501
 
460
502
  if @indent == true then
461
503
  if doc_element.children.last.children.any? \
@@ -468,61 +510,77 @@ class Rexslt
468
510
 
469
511
  else
470
512
 
471
- indent_before(element, x, doc_element, new_indent, j) if @indent == true
472
-
473
- val = @indent == true ? x.to_s : x.to_s
474
- doc_element.add val
513
+ indent_before(element, x, new_element, new_indent, j) if @indent == true
514
+
515
+ val = @indent == true ? x.to_s : x.to_s
516
+ #jr020219 doc_element.add val
517
+ doc_element.add new_element
475
518
 
476
519
  end
477
-
520
+
478
521
  end
479
-
522
+ #new_element
523
+ #puts 'attributes: ' + new_element.attributes.inspect if @debug
524
+
480
525
  end
481
-
482
- def value_of(x, element, i)
483
-
526
+
527
+ def value_of(x, elementx, i)
528
+
529
+ puts 'value_of: ' + elementx.to_s.inspect if @debug
530
+
484
531
  field = x.attributes[:select]
485
532
 
486
533
  o = case field
487
534
  when '.'
488
- element.value
535
+ elementx.value
489
536
  when /^\$/
490
537
  @param[field[/^\$(.*)/,1]]
491
538
  when 'position()'
492
539
  i.to_s
493
540
  else
494
- ee = element.text(field)
495
- ee
541
+ r = elementx.element(field)
542
+ if r.is_a? Rexle::Element::Attribute
543
+ r.value.to_s
544
+ elsif r.is_a? Rexle::Element
545
+ r.texts.join
546
+ else
547
+ ''
548
+ end
549
+
496
550
  end
497
-
551
+
498
552
  end
499
-
553
+
500
554
  def xsl_output()
501
555
 
502
556
  end
503
-
557
+
504
558
  def xsl_text(element, x, doc_element, indent, i)
505
559
 
506
- val = @indent == true ? padding(doc_element, indent, x) : ''
507
-
560
+ puts ('inside xsl_text x.value:' + x.inspect).debug if @debug
561
+ val = @indent == true ? padding(doc_element, indent, x) : ''
562
+
508
563
  val += if x.attributes[:"disable-output-escaping"] then
509
564
  x.value.unescape
510
565
  else
511
566
  x.value.to_s
512
567
  end
513
-
568
+
514
569
  doc_element.add_element val
515
-
570
+
516
571
  end
517
-
572
+
518
573
  def xsl_value_of(element, x, doc_element, indent, i)
519
-
574
+
575
+ #puts 'xsl_value_of: ' + x.inspect if @debug
520
576
  s = value_of(x, element,i)
577
+ puts ('xsl_value_of s: ' + s.inspect).debug if @debug
578
+
521
579
  doc_element.add_text s
522
580
  doc_element
523
-
581
+
524
582
  end
525
-
583
+
526
584
 
527
585
  def xslt_transform(raw_xsl, xml, custom_params={})
528
586
 
@@ -530,9 +588,9 @@ class Rexslt
530
588
 
531
589
  doc_xml = xml.is_a?(Rexle) ? xml : Rexle.new(xml)
532
590
 
533
- @doc_xsl = raw_xsl.is_a?(Rexle) ? raw_xsl : Rexle.new(raw_xsl)
591
+ @doc_xsl = raw_xsl.is_a?(Rexle) ? raw_xsl : Rexle.new(raw_xsl.gsub(/(?<=\<\/xsl:text>)[^<]+/,''))
534
592
  puts 'after @doc_xsl'.info if @debug
535
-
593
+
536
594
  #jr2040516 filter_out_spaces @doc_xsl.root
537
595
 
538
596
  @doc = Rexle.new '<root4></root4>', debug: @debug
@@ -541,10 +599,10 @@ class Rexslt
541
599
 
542
600
  previous_indent = 0
543
601
  @xsl_methods = %i(apply_templates value_of element if choose when copy_of
544
- attribute for_each text output call_template).map do |x|
602
+ attribute for_each text output call_template comment cdata).map do |x|
545
603
  ('xsl_' + x.to_s).to_sym
546
604
  end
547
-
605
+
548
606
  strip_space = @doc_xsl.root.element "xsl:strip-space/attribute::elements"
549
607
 
550
608
  if strip_space then
@@ -553,24 +611,25 @@ class Rexslt
553
611
  nodes = doc_xml.root.xpath "//" + element + "[text()]"
554
612
  a = nodes.select {|x| x.value.to_s.strip.empty?}
555
613
  a.each {|node| node.parent.delete node}
556
- end
614
+ end
557
615
  end
558
616
 
559
617
  h = @doc_xsl.root.element("xsl:output/attribute::*")
618
+ puts 'h: ' + h.inspect if @debug
560
619
  puts 'after h'.info if @debug
561
-
620
+
562
621
  if h and ((h[:method] and h[:method].downcase == 'html') \
563
622
  or h[:'omit-xml-declaration'] == 'yes') then
564
- @options[:declaration] = :none
623
+ @options[:declaration] = :none
565
624
  end
566
625
 
567
626
  @indent = (h and h[:indent] == 'yes') ? true : false
568
-
627
+
569
628
  params = @doc_xsl.root.xpath("xsl:param").map{|x| [x.attributes[:name], x.value]}
570
629
  @param = Hash[params].merge(custom_params) if params
571
630
  # search for params
572
-
573
-
631
+
632
+
574
633
  # fetch the templates
575
634
  #puts "Rexle:Version: " + Rexle.version
576
635
 
@@ -578,36 +637,36 @@ class Rexslt
578
637
  r.merge(x.attributes[:match] || x.attributes[:select] => x)
579
638
  end
580
639
 
581
- # using the 1st template
640
+ # using the 1st template
582
641
  xpath = String.new @templates.to_a[0][0]
583
642
  out = read_node(@templates.to_a[0][-1], doc_xml.element(xpath), @doc.root, indent)
584
643
 
585
644
  puts ('out: ' + out.inspect).debug if @debug
586
-
645
+
587
646
  html = @doc.root.element('html')
588
-
647
+
589
648
  if html then
590
-
649
+
591
650
  if h and h[:'omit-xml-declaration'] != 'yes' then
592
651
  else
593
652
  @options[:declaration] = :none
594
653
  end
595
-
596
- end
654
+
655
+ end
597
656
 
598
657
  if @doc_xsl.root.element('xsl:output[@method="html"]') or html then
599
-
658
+
600
659
  head = @doc.root.element('html/head')
601
660
 
602
661
  if head and not head.element('meta[@content]') then
603
-
662
+
604
663
  h = {
605
- :'http-equiv' => "Content-Type",
664
+ :'http-equiv' => "Content-Type",
606
665
  content: 'text/html; charset=utf-8'
607
666
  }
608
667
  meta_element = Rexle::Element.new('meta', attributes: h)
609
668
  child = head.element('*')
610
-
669
+
611
670
  if child then
612
671
  child.insert_before meta_element
613
672
  else
@@ -615,8 +674,8 @@ class Rexslt
615
674
  end
616
675
 
617
676
  end
618
- end
619
-
677
+ end
678
+
620
679
  out
621
680
 
622
681
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexslt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.12
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,74 +11,74 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMjAxMTk1MjQyWhcN
15
- MjAwMjAxMTk1MjQyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCr1Aj5
17
- q9c4JQkcjTisuXqjdp5xqnBYNA5ZSWRD7mjzwdKajCSFEE/Qbe5W51pdJLf7T4F+
18
- nOSQVOQ7bbtUFlmaAVXmzYXM84+kp7yZJVrTPyIFgsO+2trIizZ0HsE4H2CPBhrX
19
- oefgXQCumOBjwBswUzD9qqvNAX0l0LVa3QBidwA4IHcc8RIFnu/1JOk11GCHYYNR
20
- T31kN5iGvSH1Cl4cXYuD5PX44bTJ+zdBWusZcCV71MM/QLEglSL9HiS/PNjExMTk
21
- 8UuT6uuD2n090OotL4qyotVODvetCkIMQullgGBYSQtT/R8sN35Tg64443Gmh4Ft
22
- u92AmIFSzgGjZLFlc6B/McqxAFxhHCehyGo2X6vvOBz/vExmWpq8FhXHaw726cpw
23
- iRaBhcCBoxyp1OAUTGnLMbqVyP47KSMEtz+wc1fGR9mUmsPc1hTM0j25scygOK26
24
- 6pugoVyZLVNIGKnEXQGOGEknDqxHT4jYiYUVXV2N3/0OctBZlsulD/aTX5cCAwEA
25
- AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUljB/mcn+
26
- iSaM5h8WLBvmN14qEaIwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9i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CERTIFICATE-----
38
- date: 2019-02-01 00:00:00.000000000 Z
38
+ date: 2022-02-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: rxfhelper
41
+ name: rxfreader
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.4'
46
+ version: '0.2'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.4.3
49
+ version: 0.2.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.4'
56
+ version: '0.2'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.4.3
59
+ version: 0.2.1
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rexle
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.4'
66
+ version: '1.5'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.4.12
69
+ version: 1.5.14
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.4'
76
+ version: '1.5'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 1.4.12
79
+ version: 1.5.14
80
80
  description:
81
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
82
82
  executables: []
83
83
  extensions: []
84
84
  extra_rdoc_files: []
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.2
106
+ rubygems_version: 3.2.22
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Rexslt is an XSLT processor written purely in Ruby
metadata.gz.sig CHANGED
Binary file