asip-meteor 0.9.3.1 → 0.9.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/meteor.rb +660 -570
- metadata +3 -3
data/lib/meteor.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -* coding: UTF-8 -*-
|
2
2
|
# Meteor - A lightweight (X)HTML & XML parser
|
3
3
|
#
|
4
|
-
# Copyright (C) 2008 Yasumasa Ashida.
|
4
|
+
# Copyright (C) 2008-2009 Yasumasa Ashida.
|
5
5
|
#
|
6
6
|
# This program is free software; you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published by
|
@@ -18,18 +18,19 @@
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
#
|
20
20
|
# @author Yasumasa Ashida
|
21
|
-
# @version 0.9.3.
|
21
|
+
# @version 0.9.3.2
|
22
22
|
#
|
23
23
|
|
24
24
|
module Meteor
|
25
25
|
|
26
|
-
VERSION = "0.9.3.
|
26
|
+
VERSION = "0.9.3.2"
|
27
27
|
|
28
28
|
RUBY_VERSION_1_9_0 = '1.9.0'
|
29
29
|
|
30
30
|
if RUBY_VERSION < RUBY_VERSION_1_9_0 then
|
31
31
|
require 'Kconv'
|
32
|
-
E_UTF8 = 'UTF8'
|
32
|
+
#E_UTF8 = 'UTF8'
|
33
|
+
$KCODE = 'UTF8'
|
33
34
|
end
|
34
35
|
|
35
36
|
ZERO = 0
|
@@ -41,16 +42,18 @@ module Meteor
|
|
41
42
|
SIX = 6
|
42
43
|
SEVEN = 7
|
43
44
|
|
44
|
-
CONTENT_STR = ':content'
|
45
|
-
|
46
45
|
#
|
47
46
|
# 要素クラス
|
48
47
|
#
|
49
|
-
class Element
|
48
|
+
class Element
|
50
49
|
|
51
50
|
#
|
52
51
|
# イニシャライザ
|
53
52
|
# @param [Array] args 引数配列
|
53
|
+
# @overload def initialize(name)
|
54
|
+
# @param [String] name 名前
|
55
|
+
# @overload def initialize(elm)
|
56
|
+
# @param [Meteor::Element] elm 要素
|
54
57
|
#
|
55
58
|
def initialize(*args)
|
56
59
|
case args.length
|
@@ -134,22 +137,20 @@ module Meteor
|
|
134
137
|
end
|
135
138
|
private :initialize_e
|
136
139
|
|
137
|
-
attr_accessor :name
|
138
|
-
attr_accessor :attributes
|
139
|
-
attr_accessor :mixed_content
|
140
|
-
attr_accessor :pattern
|
141
|
-
|
142
|
-
#
|
143
|
-
attr_accessor :
|
144
|
-
attr_accessor :
|
145
|
-
attr_accessor :
|
146
|
-
attr_accessor :
|
147
|
-
attr_accessor :parser #パーサ
|
148
|
-
attr_accessor :type_value #タイプ属性
|
140
|
+
attr_accessor :name #[String] 要素名
|
141
|
+
attr_accessor :attributes #[String] 属性群
|
142
|
+
attr_accessor :mixed_content #[String] 内容
|
143
|
+
attr_accessor :pattern #[String] パターン
|
144
|
+
attr_accessor :document_sync #[true,false] ドキュメント更新フラグ
|
145
|
+
attr_accessor :empty #[true,false] 内容存在フラグ
|
146
|
+
attr_accessor :cx #[true,false] コメント拡張タグフラグ
|
147
|
+
attr_accessor :mono #[true,false] 子要素存在フラグ
|
148
|
+
attr_accessor :parser #[Meteor::Parser] パーサ
|
149
|
+
attr_accessor :type_value #[String] タイプ属性
|
149
150
|
#attr_accessor :arguments #パターン変更用属性マップ
|
150
|
-
attr_accessor :usable
|
151
|
-
attr_accessor :origin
|
152
|
-
attr_accessor :copy
|
151
|
+
attr_accessor :usable #[true,false] 有効・無効フラグ
|
152
|
+
attr_accessor :origin #[Meteor::Element] 原本ポインタ
|
153
|
+
attr_accessor :copy #[Meteor::Element] 複製ポインタ
|
153
154
|
|
154
155
|
#
|
155
156
|
# コピーを作成する
|
@@ -157,9 +158,9 @@ module Meteor
|
|
157
158
|
#
|
158
159
|
def self.new!(*args)
|
159
160
|
case args.length
|
160
|
-
when ONE
|
161
|
-
|
162
|
-
|
161
|
+
#when ONE
|
162
|
+
# #self.new_1!(args[0])
|
163
|
+
# args[0].clone
|
163
164
|
when TWO
|
164
165
|
@obj = args[1].root_element.element
|
165
166
|
if @obj then
|
@@ -199,9 +200,31 @@ module Meteor
|
|
199
200
|
|
200
201
|
#
|
201
202
|
# 子要素を取得する
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
203
|
+
# @overload def child(elm_name)
|
204
|
+
# @param [String] elm_name 要素名
|
205
|
+
# @return [Meteor::Element] 要素
|
206
|
+
# @overload def child(elm_name,attr_name,attr_value)
|
207
|
+
# @param [String] elm_name 要素名
|
208
|
+
# @param [String] attr_name 属性名
|
209
|
+
# @param [String] attr_value 属性値
|
210
|
+
# @return [Meteor::Element] 要素
|
211
|
+
# @overload def child(attr_name,attr_value)
|
212
|
+
# @param [String] attr_name 属性名
|
213
|
+
# @param [String] attr_value 属性値
|
214
|
+
# @return [Meteor::Element] 要素
|
215
|
+
# @overload def child(elm_name,attr_name1,attr_value1,attr_name2,attr_value2)
|
216
|
+
# @param [String] elm_name 要素の名前
|
217
|
+
# @param [String] attr_name1 属性名1
|
218
|
+
# @param [String] attr_value1 属性値2
|
219
|
+
# @param [String] attr_name2 属性名2
|
220
|
+
# @param [String] attr_value2 属性値2
|
221
|
+
# @return [Meteor::Element] 要素
|
222
|
+
# @overload def child(attr_name1,attr_value1,attr_name2,attr_value2)
|
223
|
+
# @param [String] attr_name1 属性名1
|
224
|
+
# @param [String] attr_value1 属性値2
|
225
|
+
# @param [String] attr_name2 属性名2
|
226
|
+
# @param [String] attr_value2 属性値2
|
227
|
+
# @return [Meteor::Element] 要素
|
205
228
|
#
|
206
229
|
def child(*args)
|
207
230
|
@parser.element(*args)
|
@@ -209,37 +232,59 @@ module Meteor
|
|
209
232
|
|
210
233
|
#
|
211
234
|
# CX(コメント拡張)タグを取得する
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
235
|
+
# @overload def cxtag(elm_name,id)
|
236
|
+
# @param [String] elm_name 要素名
|
237
|
+
# @param [String] id ID属性値
|
238
|
+
# @return [Meteor::Element] 要素
|
239
|
+
# @overload def cxtag(id)
|
240
|
+
# @param [String] id ID属性値
|
241
|
+
# @return [Meteor::Element] 要素
|
215
242
|
#
|
216
243
|
def cxtag(*args)
|
217
244
|
@parser.cxtag(*args)
|
218
245
|
end
|
246
|
+
|
219
247
|
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
248
|
+
# @overload def attribute(attr_name,attr_value)
|
249
|
+
# 要素の属性をセットする
|
250
|
+
# @param [String] attr_name 属性名
|
251
|
+
# @param [String,true,false] attr_value 属性値
|
252
|
+
# @return [Meteor::Element] 要素
|
253
|
+
# @overload def attribute(attr_name)
|
254
|
+
# 要素の属性値を取得する
|
255
|
+
# @param [String] attr_name 属性名
|
256
|
+
# @return [String] 属性値
|
224
257
|
#
|
225
258
|
def attribute(*args)
|
226
259
|
@parser.attribute(self,*args)
|
227
260
|
end
|
228
261
|
|
229
262
|
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
263
|
+
# @overload def attribute_map(attr_map)
|
264
|
+
# 属性マップをセットする
|
265
|
+
# @param [Meteor::AttributeMap] attrMap 属性マップ
|
266
|
+
# @return [Meteor::Element] 要素
|
267
|
+
# @overload def attribute_map()
|
268
|
+
# 属性マップを取得する
|
269
|
+
# @return [Meteor::AttributeMap] 属性マップ
|
233
270
|
#
|
234
|
-
def attribute_map
|
235
|
-
@parser.attribute_map(self)
|
271
|
+
def attribute_map(*args)
|
272
|
+
@parser.attribute_map(self,*args)
|
236
273
|
end
|
237
274
|
|
238
275
|
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
276
|
+
# @overload def content(content,entity_ref=true)
|
277
|
+
# 要素の内容をセットする
|
278
|
+
# @param [String] content 要素の内容
|
279
|
+
# @param [true,false] entity_ref エンティティ参照フラグ
|
280
|
+
# @return [Meteor::Element] 要素
|
281
|
+
# @overload def content(content)
|
282
|
+
# 要素の内容をセットする
|
283
|
+
# @param [String] content 要素の内容
|
284
|
+
# @return [Meteor::Element] 要素
|
285
|
+
# @overload def content()
|
286
|
+
# 要素の内容を取得する
|
287
|
+
# @return [String] 内容
|
243
288
|
#
|
244
289
|
def content(*args)
|
245
290
|
@parser.content(self,*args)
|
@@ -247,52 +292,55 @@ module Meteor
|
|
247
292
|
|
248
293
|
#
|
249
294
|
# 内容をセットする
|
250
|
-
#
|
251
295
|
# @param [String] value 内容
|
296
|
+
# @return [Meteor::Element] 要素
|
252
297
|
#
|
253
298
|
def content=(value)
|
254
299
|
@parser.content(self,value)
|
255
300
|
end
|
256
301
|
|
257
302
|
#
|
258
|
-
#
|
259
|
-
#
|
303
|
+
# 属性をセットする
|
260
304
|
# @param [String] name 属性の名前
|
261
|
-
# @param [String] value 属性の値
|
305
|
+
# @param [String] value 属性の値
|
306
|
+
# @return [Meteor::Element] 要素
|
262
307
|
#
|
263
308
|
def []=(name,value)
|
264
|
-
|
265
|
-
if CONTENT_STR != name then
|
266
|
-
attribute(name,value)
|
267
|
-
else
|
268
|
-
|
269
|
-
end
|
309
|
+
##if !name.kind_of?(String) || CONTENT_STR != name then
|
310
|
+
#if CONTENT_STR != name then
|
311
|
+
@parser.attribute(self,name,value)
|
312
|
+
#else
|
313
|
+
# @parser.content(self,value)
|
314
|
+
#end
|
270
315
|
end
|
271
316
|
|
272
317
|
#
|
273
|
-
#
|
274
|
-
#
|
318
|
+
# 属性の値を取得する
|
275
319
|
# @param [String] name 属性の名前
|
276
|
-
# @return [String] 属性の値
|
320
|
+
# @return [String] 属性の値
|
277
321
|
#
|
278
322
|
def [](name)
|
279
|
-
|
280
|
-
if CONTENT_STR != name then
|
281
|
-
attribute(name)
|
282
|
-
else
|
283
|
-
|
284
|
-
end
|
323
|
+
##if !name.kind_of?(String) || CONTENT_STR != name then
|
324
|
+
#if CONTENT_STR != name then
|
325
|
+
@parser.attribute(self,name)
|
326
|
+
#else
|
327
|
+
# content()
|
328
|
+
#end
|
285
329
|
end
|
286
330
|
|
287
331
|
#
|
288
|
-
#
|
289
|
-
#
|
290
|
-
# @
|
332
|
+
# 要素の属性を消す
|
333
|
+
# @param [String] attr_name 属性名
|
334
|
+
# @return [Meteor::Element] 要素
|
291
335
|
#
|
292
|
-
def remove_attribute(
|
293
|
-
@parser.remove_attribute(self
|
336
|
+
def remove_attribute(attr_name)
|
337
|
+
@parser.remove_attribute(self,attr_name)
|
294
338
|
end
|
295
339
|
|
340
|
+
#
|
341
|
+
# ドキュメントをセットする
|
342
|
+
# @param [String] doc ドキュメント
|
343
|
+
#
|
296
344
|
def document=(doc)
|
297
345
|
@document_sync = false
|
298
346
|
@document = doc
|
@@ -342,6 +390,9 @@ module Meteor
|
|
342
390
|
@parser.remove_element(self)
|
343
391
|
end
|
344
392
|
|
393
|
+
#
|
394
|
+
# 反映する
|
395
|
+
#
|
345
396
|
def flush
|
346
397
|
@parser.flush
|
347
398
|
end
|
@@ -380,12 +431,12 @@ module Meteor
|
|
380
431
|
#@element = nil
|
381
432
|
end
|
382
433
|
|
383
|
-
attr_accessor :content_type
|
384
|
-
attr_accessor :kaigyo_code
|
385
|
-
attr_accessor :character_encoding
|
386
|
-
attr_accessor :document
|
387
|
-
attr_accessor :hook_document
|
388
|
-
attr_accessor :element
|
434
|
+
attr_accessor :content_type #[String] コンテントタイプ
|
435
|
+
attr_accessor :kaigyo_code #[String] 改行コード
|
436
|
+
attr_accessor :character_encoding #[String] エンコーディング
|
437
|
+
attr_accessor :document #[String] ドキュメント
|
438
|
+
attr_accessor :hook_document #[String] フック・ドキュメント
|
439
|
+
attr_accessor :element #[Meteor::Element] 要素
|
389
440
|
end
|
390
441
|
|
391
442
|
#
|
@@ -393,6 +444,12 @@ module Meteor
|
|
393
444
|
#
|
394
445
|
class AttributeMap
|
395
446
|
|
447
|
+
#
|
448
|
+
# イニシャライザ
|
449
|
+
# @overload def initialize
|
450
|
+
# @overload def initialize(attr_map)
|
451
|
+
# @param [Meteor::AttributeMap] attr_map 属性マップ
|
452
|
+
#
|
396
453
|
def initialize(*args)
|
397
454
|
case args.length
|
398
455
|
when ZERO
|
@@ -418,6 +475,7 @@ module Meteor
|
|
418
475
|
|
419
476
|
#
|
420
477
|
# イニシャライザ
|
478
|
+
# @param [Meteor::AttributeMap] attr_map 属性マップ
|
421
479
|
#
|
422
480
|
def initialize_1(attr_map)
|
423
481
|
#@map = Marshal.load(Marshal.dump(attrMap.map))
|
@@ -431,7 +489,6 @@ module Meteor
|
|
431
489
|
|
432
490
|
#
|
433
491
|
# 属性名と属性値を対としてセットする
|
434
|
-
#
|
435
492
|
# @param [String] name 属性名
|
436
493
|
# @param [String] value 属性値
|
437
494
|
#
|
@@ -461,7 +518,6 @@ module Meteor
|
|
461
518
|
|
462
519
|
#
|
463
520
|
# 属性名配列を取得する
|
464
|
-
#
|
465
521
|
# @return [Array] 属性名配列
|
466
522
|
#
|
467
523
|
def names
|
@@ -473,8 +529,7 @@ module Meteor
|
|
473
529
|
end
|
474
530
|
|
475
531
|
#
|
476
|
-
# 属性名で属性値を取得する
|
477
|
-
#
|
532
|
+
# 属性名で属性値を取得する
|
478
533
|
# @param [String] name 属性名
|
479
534
|
# @return [String] 属性値
|
480
535
|
#
|
@@ -485,8 +540,7 @@ module Meteor
|
|
485
540
|
end
|
486
541
|
|
487
542
|
#
|
488
|
-
# 属性名に対応した属性を削除する
|
489
|
-
#
|
543
|
+
# 属性名に対応した属性を削除する
|
490
544
|
# @param name 属性名
|
491
545
|
#
|
492
546
|
def delete(name)
|
@@ -497,9 +551,8 @@ module Meteor
|
|
497
551
|
end
|
498
552
|
|
499
553
|
#
|
500
|
-
# 属性名で属性の変更状況を取得する
|
501
|
-
#
|
502
|
-
# @return [TrueClass,FalseClass] 属性の変更状況
|
554
|
+
# 属性名で属性の変更状況を取得する
|
555
|
+
# @return [true,false] 属性の変更状況
|
503
556
|
#
|
504
557
|
def changed(name)
|
505
558
|
if @map[name] then
|
@@ -509,8 +562,7 @@ module Meteor
|
|
509
562
|
|
510
563
|
#
|
511
564
|
# 属性名で属性の削除状況を取得する
|
512
|
-
#
|
513
|
-
# @return [TrueClass,FalseClass] 属性の削除状況
|
565
|
+
# @return [true,false] 属性の削除状況
|
514
566
|
#
|
515
567
|
def removed(name)
|
516
568
|
if @map[name] then
|
@@ -557,10 +609,10 @@ module Meteor
|
|
557
609
|
#@removed = false
|
558
610
|
end
|
559
611
|
|
560
|
-
attr_accessor :name
|
561
|
-
attr_accessor :value
|
562
|
-
attr_accessor :changed
|
563
|
-
attr_accessor :removed
|
612
|
+
attr_accessor :name #[String] 名前
|
613
|
+
attr_accessor :value #[String] 値
|
614
|
+
attr_accessor :changed #[true,false] 更新フラグ
|
615
|
+
attr_accessor :removed #[true,false] 削除フラグ
|
564
616
|
|
565
617
|
end
|
566
618
|
|
@@ -583,12 +635,17 @@ module Meteor
|
|
583
635
|
SLASH = '/'
|
584
636
|
ENC_UTF8 = 'UTF-8'
|
585
637
|
|
586
|
-
attr_accessor :base_dir
|
587
|
-
attr_accessor :base_encoding
|
638
|
+
attr_accessor :base_dir #[String] 基準ディレクトリ
|
639
|
+
attr_accessor :base_encoding #[String] デフォルトエンコーディング
|
588
640
|
|
589
641
|
#
|
590
642
|
# イニシャライザ
|
591
|
-
# @
|
643
|
+
# @overload def initialize()
|
644
|
+
# @overload def initialize(bs_dir)
|
645
|
+
# @param [String] bs_dir 基準ディレクトリ
|
646
|
+
# @overload def initialize(bs_dir,bs_encoding)
|
647
|
+
# @param [String] bs_dir 基準ディレクトリ
|
648
|
+
# @param [String] bs_encoding デフォルトエンコーディング
|
592
649
|
#
|
593
650
|
def initialize(*args)
|
594
651
|
case args.length
|
@@ -637,9 +694,21 @@ module Meteor
|
|
637
694
|
private :initialize_1
|
638
695
|
|
639
696
|
#
|
640
|
-
#
|
641
|
-
#
|
642
|
-
#
|
697
|
+
# @overload def parser(type,relative_path,encoding)
|
698
|
+
# パーサをセットする
|
699
|
+
# @param [Fixnum] type パーサのタイプ
|
700
|
+
# @param [String] relative_path 相対ファイルパス
|
701
|
+
# @param [String] encoding エンコーディング
|
702
|
+
# @return [Meteor::Parser] パーサ
|
703
|
+
# @overload def parser(type,relative_path)
|
704
|
+
# パーサをセットする
|
705
|
+
# @param [Fixnum] type パーサのタイプ
|
706
|
+
# @param [String] relative_path 相対ファイルパス
|
707
|
+
# @return [Meteor::Parser] パーサ
|
708
|
+
# @overload def parser(key)
|
709
|
+
# パーサを取得する
|
710
|
+
# @param [String] key キー
|
711
|
+
# @return [Meteor::Parser] パーサ
|
643
712
|
#
|
644
713
|
def parser(*args)
|
645
714
|
case args.length
|
@@ -652,27 +721,8 @@ module Meteor
|
|
652
721
|
end
|
653
722
|
end
|
654
723
|
|
655
|
-
#
|
656
|
-
# パーサを取得する
|
657
|
-
# @param [String] key キー
|
658
|
-
# @return [Meteor::Parser] パーサ
|
659
|
-
#
|
660
|
-
def parser_1(key)
|
661
|
-
@pif = @cache[key]
|
662
|
-
|
663
|
-
if @pif.instance_of?(Meteor::Core::Html::ParserImpl) then
|
664
|
-
Meteor::Core::Html::ParserImpl.new(@pif)
|
665
|
-
elsif @pif.instance_of?(Meteor::Core::Xhtml::ParserImpl) then
|
666
|
-
Meteor::Core::Xhtml::ParserImpl.new(@pif)
|
667
|
-
elsif @pif.instance_of?(Meteor::Core::Xml::ParserImpl) then
|
668
|
-
Meteor::Core::Xml::ParserImpl.new(@pif)
|
669
|
-
end
|
670
|
-
end
|
671
|
-
private :parser_1
|
672
|
-
|
673
724
|
#
|
674
725
|
# パーサをセットする
|
675
|
-
#
|
676
726
|
# @param [Fixnum] type パーサのタイプ
|
677
727
|
# @param [String] relative_path 相対ファイルパス
|
678
728
|
# @param [String] encoding エンコーディング
|
@@ -692,17 +742,14 @@ module Meteor
|
|
692
742
|
when Parser::HTML then
|
693
743
|
html = Meteor::Core::Html::ParserImpl.new()
|
694
744
|
html.read(File.expand_path(relative_path,@base_dir), encoding)
|
695
|
-
html.doc_type = Parser::HTML
|
696
745
|
@cache[relative_url] = html
|
697
746
|
when Parser::XHTML then
|
698
747
|
xhtml = Meteor::Core::Xhtml::ParserImpl.new()
|
699
748
|
xhtml.read(File.expand_path(relative_path,@base_dir), encoding)
|
700
|
-
xhtml.doc_type = Parser::XHTML
|
701
749
|
@cache[relative_url] = xhtml
|
702
750
|
when Parser::XML then
|
703
751
|
xml = Meteor::Core::Xml::ParserImpl.new()
|
704
752
|
xml.read(File.expand_path(relative_path,@base_dir), encoding)
|
705
|
-
xml.doc_type = Parser::XML
|
706
753
|
@cache[relative_url] = xml
|
707
754
|
end
|
708
755
|
end
|
@@ -710,7 +757,6 @@ module Meteor
|
|
710
757
|
|
711
758
|
#
|
712
759
|
# パーサをセットする
|
713
|
-
#
|
714
760
|
# @param [Fixnum] type パーサのタイプ
|
715
761
|
# @param [String] relative_path 相対ファイルパス
|
716
762
|
# @return [Meteor::Parser] パーサ
|
@@ -719,27 +765,24 @@ module Meteor
|
|
719
765
|
|
720
766
|
paths = File.split(relative_path)
|
721
767
|
|
722
|
-
if
|
768
|
+
if CURRENT_DIR.eql?(paths[0]) then
|
723
769
|
relative_url = File.basename(paths[1],ABST_EXT_NAME)
|
724
770
|
else
|
725
|
-
relative_url = [paths[0],File.basename(paths[1],
|
771
|
+
relative_url = [paths[0],File.basename(paths[1],ABST_EXT_NAME)].join(SLASH)
|
726
772
|
end
|
727
773
|
|
728
774
|
case type
|
729
775
|
when Parser::HTML then
|
730
776
|
html = Meteor::Core::Html::ParserImpl.new()
|
731
777
|
html.read(File.expand_path(relative_path,@base_dir), @base_encoding)
|
732
|
-
html.doc_type = Parser::HTML
|
733
778
|
@cache[relative_url] = html
|
734
779
|
when Parser::XHTML then
|
735
780
|
xhtml = Meteor::Core::Xhtml::ParserImpl.new()
|
736
781
|
xhtml.read(File.expand_path(relative_path,@base_dir), @base_encoding)
|
737
|
-
xhtml.doc_type = Parser::XHTML
|
738
782
|
@cache[relative_url] = xhtml
|
739
783
|
when Parser::XML then
|
740
784
|
xml = Meteor::Core::Xml::ParserImpl.new()
|
741
785
|
xml.read(File.expand_path(relative_path,@base_dir), @base_encoding)
|
742
|
-
xml.doc_type = Parser::XML
|
743
786
|
@cache[relative_url] = xml
|
744
787
|
end
|
745
788
|
|
@@ -747,8 +790,25 @@ module Meteor
|
|
747
790
|
private :parser_2
|
748
791
|
|
749
792
|
#
|
750
|
-
#
|
793
|
+
# パーサを取得する
|
794
|
+
# @param [String] key キー
|
795
|
+
# @return [Meteor::Parser] パーサ
|
751
796
|
#
|
797
|
+
def parser_1(key)
|
798
|
+
@pif = @cache[key]
|
799
|
+
|
800
|
+
if Meteor::Parser::HTML == @pif.doc_type then
|
801
|
+
Meteor::Core::Html::ParserImpl.new(@pif)
|
802
|
+
elsif Meteor::Parser::XHTML == @pif.doc_type then
|
803
|
+
Meteor::Core::Xhtml::ParserImpl.new(@pif)
|
804
|
+
elsif Meteor::Parser::XML == @pif.doc_type then
|
805
|
+
Meteor::Core::Xml::ParserImpl.new(@pif)
|
806
|
+
end
|
807
|
+
end
|
808
|
+
private :parser_1
|
809
|
+
|
810
|
+
#
|
811
|
+
# パーサをセットする
|
752
812
|
# @param [Fixnum] type パーサのタイプ
|
753
813
|
# @param [String] relative_url 相対URL
|
754
814
|
# @param [String] document ドキュメント
|
@@ -759,38 +819,34 @@ module Meteor
|
|
759
819
|
when Parser::HTML then
|
760
820
|
html = Meteor::Core::Html::ParserImpl.new()
|
761
821
|
html.parse(document)
|
762
|
-
html.doc_type = Parser::HTML
|
763
822
|
@cache[relative_url] = html
|
764
823
|
when Parser::XHTML then
|
765
824
|
xhtml = Meteor::Core::Xhtml::ParserImpl.new()
|
766
825
|
xhtml.parse(document)
|
767
|
-
xhtml.doc_type = Parser::XHTML
|
768
826
|
@cache[relative_url] = xhtml
|
769
827
|
when Parser::XML then
|
770
828
|
xml = Meteor::Core::Xml::ParserImpl.new()
|
771
829
|
xml.parse(document)
|
772
|
-
xml.doc_type = Parser::XML
|
773
830
|
@cache[relative_url] = xml
|
774
831
|
end
|
775
832
|
end
|
776
833
|
|
777
834
|
#
|
778
835
|
# パーサをセットする
|
779
|
-
# @param [String]
|
780
|
-
# @param [Meteor::Parser]
|
836
|
+
# @param [String] kay キー
|
837
|
+
# @param [Meteor::Parser] ps パーサ
|
781
838
|
#
|
782
|
-
def []=(
|
783
|
-
@cache[path] =
|
839
|
+
def []=(key,ps)
|
840
|
+
@cache[path] = ps
|
784
841
|
end
|
785
842
|
|
786
843
|
#
|
787
844
|
# パーサを取得する
|
788
|
-
#
|
789
|
-
#
|
845
|
+
# @param [String] key キー
|
790
846
|
# @return [Meteor::Parser] パーサ
|
791
847
|
#
|
792
|
-
def [](
|
793
|
-
self.parser(
|
848
|
+
def [](key)
|
849
|
+
self.parser(key)
|
794
850
|
end
|
795
851
|
|
796
852
|
end
|
@@ -869,9 +925,9 @@ module Meteor
|
|
869
925
|
DOUBLE_QUATATION = '"'
|
870
926
|
TAG_OPEN = '<'
|
871
927
|
TAG_OPEN3 = '</'
|
872
|
-
TAG_OPEN4 = '<\\\\/'
|
928
|
+
#TAG_OPEN4 = '<\\\\/'
|
873
929
|
TAG_CLOSE = '>'
|
874
|
-
TAG_CLOSE2 = '\\/>'
|
930
|
+
#TAG_CLOSE2 = '\\/>'
|
875
931
|
TAG_CLOSE3 = '/>'
|
876
932
|
ATTR_EQ = '="'
|
877
933
|
#element
|
@@ -1027,24 +1083,6 @@ module Meteor
|
|
1027
1083
|
#SUB_REGEX2 = '\\1\\1\\\\\\\\\\2'
|
1028
1084
|
#SUB_REGEX3 = '\\1\\1\\1\\1\\\\\\\\\\\\\\\\\\2'
|
1029
1085
|
|
1030
|
-
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1031
|
-
MODE_BF = 'r:'
|
1032
|
-
MODE_AF = ':utf-8'
|
1033
|
-
|
1034
|
-
@@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP)
|
1035
|
-
|
1036
|
-
@@pattern_clean1 = Regexp.new(CLEAN_1)
|
1037
|
-
@@pattern_clean2 = Regexp.new(CLEAN_2)
|
1038
|
-
else
|
1039
|
-
|
1040
|
-
MODE = 'r'
|
1041
|
-
|
1042
|
-
@@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP,nil,E_UTF8)
|
1043
|
-
|
1044
|
-
@@pattern_clean1 = Regexp.new(CLEAN_1,nil,E_UTF8)
|
1045
|
-
@@pattern_clean2 = Regexp.new(CLEAN_2,nil,E_UTF8)
|
1046
|
-
end
|
1047
|
-
|
1048
1086
|
#BRAC_OPEN_1 = "\\\("
|
1049
1087
|
#BRAC_OPEN_2 = "\\\\\\("
|
1050
1088
|
#BRAC_CLOSE_1 = "\\\)"
|
@@ -1082,11 +1120,29 @@ module Meteor
|
|
1082
1120
|
|
1083
1121
|
#@@pattern_sub_regex1 = Regexp.new(SUB_REGEX1)
|
1084
1122
|
|
1123
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1124
|
+
MODE_UTF8 = 'r:UTF-8'
|
1125
|
+
MODE_BF = 'r:'
|
1126
|
+
MODE_AF = ':utf-8'
|
1127
|
+
|
1128
|
+
@@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP)
|
1129
|
+
|
1130
|
+
@@pattern_clean1 = Regexp.new(CLEAN_1)
|
1131
|
+
@@pattern_clean2 = Regexp.new(CLEAN_2)
|
1132
|
+
else
|
1133
|
+
|
1134
|
+
MODE = 'r'
|
1135
|
+
|
1136
|
+
@@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP)
|
1137
|
+
|
1138
|
+
@@pattern_clean1 = Regexp.new(CLEAN_1)
|
1139
|
+
@@pattern_clean2 = Regexp.new(CLEAN_2)
|
1140
|
+
end
|
1141
|
+
|
1085
1142
|
#
|
1086
1143
|
# イニシャライザ
|
1087
|
-
# @param [Array] args 引数配列
|
1088
1144
|
#
|
1089
|
-
def initialize
|
1145
|
+
def initialize
|
1090
1146
|
#親要素
|
1091
1147
|
#@parent = nil;
|
1092
1148
|
|
@@ -1141,19 +1197,17 @@ module Meteor
|
|
1141
1197
|
|
1142
1198
|
#
|
1143
1199
|
# ドキュメントを取得する
|
1144
|
-
#
|
1145
1200
|
# @return [String] ドキュメント
|
1146
1201
|
#
|
1147
1202
|
def document
|
1148
1203
|
@root.document
|
1149
1204
|
end
|
1150
1205
|
|
1151
|
-
attr_accessor :element_cache
|
1152
|
-
attr_accessor :doc_type
|
1206
|
+
attr_accessor :element_cache #[Hash] 要素キャッシュ
|
1207
|
+
attr_accessor :doc_type #[String] ドキュメントタイプ
|
1153
1208
|
|
1154
1209
|
#
|
1155
1210
|
# 文字エンコーディングをセットする
|
1156
|
-
#
|
1157
1211
|
# @param [String] enc 文字エンコーディング
|
1158
1212
|
#
|
1159
1213
|
def character_encoding=(enc)
|
@@ -1161,8 +1215,7 @@ module Meteor
|
|
1161
1215
|
end
|
1162
1216
|
|
1163
1217
|
#
|
1164
|
-
# 文字エンコーディングを取得する
|
1165
|
-
#
|
1218
|
+
# 文字エンコーディングを取得する
|
1166
1219
|
# @param [String] 文字エンコーディング
|
1167
1220
|
#
|
1168
1221
|
def character_encoding
|
@@ -1171,7 +1224,6 @@ module Meteor
|
|
1171
1224
|
|
1172
1225
|
#
|
1173
1226
|
# ルート要素を取得する
|
1174
|
-
#
|
1175
1227
|
# @return [Meteor::RootElement] ルート要素
|
1176
1228
|
#
|
1177
1229
|
def root_element
|
@@ -1180,7 +1232,6 @@ module Meteor
|
|
1180
1232
|
|
1181
1233
|
#
|
1182
1234
|
# ファイルを読み込み、パーサにセットする
|
1183
|
-
#
|
1184
1235
|
# @param [String] filePath 入力ファイルの絶対パス
|
1185
1236
|
# @param [String] encoding 入力ファイルの文字コード
|
1186
1237
|
#
|
@@ -1191,7 +1242,8 @@ module Meteor
|
|
1191
1242
|
#ファイルのオープン
|
1192
1243
|
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1193
1244
|
if ParserFactory::ENC_UTF8.eql?(encoding) then
|
1194
|
-
io = File.open(file_path,MODE_BF << encoding)
|
1245
|
+
#io = File.open(file_path,MODE_BF << encoding)
|
1246
|
+
io = File.open(file_path,MODE_UTF8)
|
1195
1247
|
else
|
1196
1248
|
io = File.open(file_path,MODE_BF << encoding << MODE_AF)
|
1197
1249
|
end
|
@@ -1203,8 +1255,8 @@ module Meteor
|
|
1203
1255
|
io = open(file_path,MODE)
|
1204
1256
|
@root.document = io.read
|
1205
1257
|
#@root.document = @root.document.kconv(get_encoding(), Kconv.guess(@root.document))
|
1206
|
-
|
1207
|
-
enc = get_encoding
|
1258
|
+
enc = Kconv.guess(@root.document)
|
1259
|
+
#enc = get_encoding
|
1208
1260
|
if !Kconv::UTF8.equal?(enc) then
|
1209
1261
|
@root.document = @root.document.kconv(Kconv::UTF8, enc)
|
1210
1262
|
end
|
@@ -1224,39 +1276,59 @@ module Meteor
|
|
1224
1276
|
# e.printStackTrace();
|
1225
1277
|
# this.setDocument(EMPTY);
|
1226
1278
|
#}
|
1227
|
-
|
1279
|
+
#
|
1280
|
+
#def get_encoding()
|
1281
|
+
# case @character_encoding
|
1282
|
+
# when 'UTF-8','UTF8','u','U'
|
1283
|
+
# @encoding = 'UTF8'
|
1284
|
+
# Kconv::UTF8
|
1285
|
+
# when 'ISO-2022-JP','JIS'
|
1286
|
+
# Kconv::JIS
|
1287
|
+
# when 'Shift_JIS','SJIS','s','S'
|
1288
|
+
# @encoding = 'SJIS'
|
1289
|
+
# Kconv::SJIS
|
1290
|
+
# when 'EUC-JP','EUC','e','E'
|
1291
|
+
# @encoding = 'EUC'
|
1292
|
+
# Kconv::EUC
|
1293
|
+
# when 'ASCII'
|
1294
|
+
# Kconv::ASCII
|
1295
|
+
# #when "UTF-16"
|
1296
|
+
# # return KConv::UTF16
|
1297
|
+
# else
|
1298
|
+
# Kconv::UTF8
|
1299
|
+
# end
|
1300
|
+
#end
|
1301
|
+
#private :get_encoding
|
1228
1302
|
end
|
1229
1303
|
|
1230
|
-
#if RUBY_VERSION < RUBY_VERSION_1_9_0 then
|
1231
|
-
def get_encoding()
|
1232
|
-
case @character_encoding
|
1233
|
-
when 'UTF-8','UTF8','u','U'
|
1234
|
-
@encoding = 'UTF8'
|
1235
|
-
Kconv::UTF8
|
1236
|
-
when 'ISO-2022-JP','JIS'
|
1237
|
-
Kconv::JIS
|
1238
|
-
when 'Shift_JIS','SJIS','s','S'
|
1239
|
-
@encoding = 'SJIS'
|
1240
|
-
Kconv::SJIS
|
1241
|
-
when 'EUC-JP','EUC','e','E'
|
1242
|
-
@encoding = 'EUC'
|
1243
|
-
Kconv::EUC
|
1244
|
-
when 'ASCII'
|
1245
|
-
Kconv::ASCII
|
1246
|
-
#when "UTF-16"
|
1247
|
-
# return KConv::UTF16
|
1248
|
-
else
|
1249
|
-
Kconv::UTF8
|
1250
|
-
end
|
1251
|
-
end
|
1252
|
-
private :get_encoding
|
1253
|
-
#end
|
1254
1304
|
|
1255
1305
|
#
|
1256
1306
|
# 要素を取得する
|
1257
|
-
#
|
1258
|
-
#
|
1259
|
-
#
|
1307
|
+
# @overload def element(elm_name)
|
1308
|
+
# @param [String] elm_name 要素名
|
1309
|
+
# @return [Meteor::Element] 要素
|
1310
|
+
# @overload def element(elm_name,attr_name,attr_value)
|
1311
|
+
# @param [String] elm_name 要素名
|
1312
|
+
# @param [String] attr_name 属性名
|
1313
|
+
# @param [String] attr_value 属性値
|
1314
|
+
# @return [Meteor::Element] 要素
|
1315
|
+
# @overload def element(attr_name,attr_value)
|
1316
|
+
# @param [String] attr_name 属性名
|
1317
|
+
# @param [String] attr_value 属性値
|
1318
|
+
# @return [Meteor::Element] 要素
|
1319
|
+
# @overload def element(elm_name,attr_name1,attr_value1,attr_name2,attr_value2)
|
1320
|
+
# @param [String] elm_name 要素の名前
|
1321
|
+
# @param [String] attr_name1 属性名1
|
1322
|
+
# @param [String] attr_value1 属性値2
|
1323
|
+
# @param [String] attr_name2 属性名2
|
1324
|
+
# @param [String] attr_value2 属性値2
|
1325
|
+
# @return [Meteor::Element] 要素
|
1326
|
+
# @overload def element(attr_name1,attr_value1,attr_name2,attr_value2)
|
1327
|
+
# @param [String] attr_name1 属性名1
|
1328
|
+
# @param [String] attr_value1 属性値2
|
1329
|
+
# @param [String] attr_name2 属性名2
|
1330
|
+
# @param [String] attr_value2 属性値2
|
1331
|
+
# @return [Meteor::Element] 要素
|
1260
1332
|
#
|
1261
1333
|
def element(*args)
|
1262
1334
|
case args.length
|
@@ -1397,7 +1469,6 @@ module Meteor
|
|
1397
1469
|
|
1398
1470
|
#
|
1399
1471
|
# 要素名と属性で検索し、要素を取得する
|
1400
|
-
#
|
1401
1472
|
# @param [String] elm_name 要素名
|
1402
1473
|
# @param [String] attrName 属性名
|
1403
1474
|
# @param [String] attr_value 属性値
|
@@ -1580,7 +1651,6 @@ module Meteor
|
|
1580
1651
|
|
1581
1652
|
#
|
1582
1653
|
# 属性(属性名="属性値")で検索し、要素を取得する
|
1583
|
-
#
|
1584
1654
|
# @param [String] attr_name 属性名
|
1585
1655
|
# @param [String] attr_value 属性値
|
1586
1656
|
# @return [Meteor::Element] 要素
|
@@ -1818,7 +1888,6 @@ module Meteor
|
|
1818
1888
|
|
1819
1889
|
#
|
1820
1890
|
# 属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
1821
|
-
#
|
1822
1891
|
# @param [String] attr_name1 属性名1
|
1823
1892
|
# @param [String] attr_value1 属性値1
|
1824
1893
|
# @param [String] attr_name2 属性名2
|
@@ -2049,26 +2118,30 @@ module Meteor
|
|
2049
2118
|
private :create_element_pattern
|
2050
2119
|
|
2051
2120
|
#
|
2052
|
-
#
|
2053
|
-
#
|
2054
|
-
#
|
2055
|
-
#
|
2121
|
+
# @overload def attribute(elm,attr_name,attr_value)
|
2122
|
+
# 要素の属性をセットする
|
2123
|
+
# @param [Meteor::Element] elm 要素
|
2124
|
+
# @param [String] attr_name 属性名
|
2125
|
+
# @param [String,true,false] attr_value 属性値
|
2126
|
+
# @return [Meteor::Element] 要素
|
2127
|
+
# @overload def attribute(elm,attr_name)
|
2128
|
+
# 要素の属性値を取得する
|
2129
|
+
# @param [Meteor::Element] elm 要素
|
2130
|
+
# @param [String] attr_name 属性名
|
2131
|
+
# @return [String] 属性値
|
2056
2132
|
#
|
2057
2133
|
def attribute(*args)
|
2058
2134
|
case args.length
|
2059
2135
|
#when ONE
|
2060
2136
|
# get_attribute_value_1(args[0])
|
2061
2137
|
when TWO
|
2062
|
-
if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
else
|
2070
|
-
raise ArgumentError
|
2071
|
-
end
|
2138
|
+
#if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
2139
|
+
get_attribute_value(args[0],args[1])
|
2140
|
+
#elsif args[0].kind_of?(String) && args[1].kind_of?(String) then
|
2141
|
+
# set_attribute_2(args[0],args[1])
|
2142
|
+
#else
|
2143
|
+
# raise ArgumentError
|
2144
|
+
#end
|
2072
2145
|
when THREE
|
2073
2146
|
args[0].document_sync = true
|
2074
2147
|
set_attribute_3(args[0],args[1],args[2])
|
@@ -2079,10 +2152,10 @@ module Meteor
|
|
2079
2152
|
|
2080
2153
|
#
|
2081
2154
|
# 要素の属性を編集する
|
2082
|
-
#
|
2083
2155
|
# @param [Meteor::Element] elm 要素
|
2084
2156
|
# @param [String] attr_name 属性名
|
2085
|
-
# @param [String,
|
2157
|
+
# @param [String,true,false] attr_value 属性値
|
2158
|
+
# @return [Meteor::Element] 要素
|
2086
2159
|
#
|
2087
2160
|
def set_attribute_3(elm,attr_name,attr_value)
|
2088
2161
|
if !elm.cx then
|
@@ -2137,87 +2210,19 @@ module Meteor
|
|
2137
2210
|
#elm.attributes << SPACE << attr_name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION
|
2138
2211
|
elm.attributes << " #{attr_name}=\"#{@_attr_value}\""
|
2139
2212
|
end
|
2140
|
-
|
2141
|
-
end
|
2142
|
-
private :edit_attributes_
|
2143
|
-
|
2144
|
-
def edit_document_1(elm)
|
2145
|
-
edit_document_2(elm,TAG_CLOSE3)
|
2146
|
-
end
|
2147
|
-
private :edit_document_1
|
2148
|
-
|
2149
|
-
def edit_document_2(elm,closer)
|
2150
|
-
if !elm.cx then
|
2151
|
-
@_attributes = elm.attributes
|
2152
|
-
#replace2regex(@_attributes)
|
2153
|
-
|
2154
|
-
if elm.empty then
|
2155
|
-
#内容あり要素の場合
|
2156
|
-
@_content = elm.mixed_content
|
2157
|
-
##replace2regex(@_content)
|
2158
|
-
#if elm.origin then
|
2159
|
-
# replace4regex(@_content)
|
2160
|
-
#else
|
2161
|
-
# replace2regex(@_content)
|
2162
|
-
#end
|
2163
|
-
|
2164
|
-
elm.document = '' << TAG_OPEN << elm.name << @_attributes << TAG_CLOSE << @_content << TAG_OPEN3 << elm.name << TAG_CLOSE
|
2165
|
-
#elm.document = "<#{elm.name}#{@_attributes}>#{@_content}</#{elm.name}>"
|
2166
|
-
else
|
2167
|
-
#空要素の場合
|
2168
|
-
elm.document = '' << TAG_OPEN << elm.name << @_attributes << closer
|
2169
|
-
end
|
2170
|
-
else
|
2171
|
-
@_content = elm.mixed_content
|
2172
|
-
#if elm.origin then
|
2173
|
-
# replace4regex(@_content)
|
2174
|
-
#else
|
2175
|
-
# replace2regex(@_content)
|
2176
|
-
#end
|
2177
|
-
|
2178
|
-
#elm.document = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2
|
2179
|
-
#elm.document << @_content << SET_CX_3 << elm.name << SET_CX_4
|
2180
|
-
elm.document = "<!-- @#{elm.name} #{elm.attributes}-->#{@_content}<!-- /@#{elm.name} -->"
|
2181
|
-
end
|
2182
|
-
|
2183
|
-
#タグ置換
|
2184
|
-
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
2185
|
-
@root.document.sub!(@pattern,elm.document)
|
2186
2213
|
end
|
2187
|
-
private :
|
2188
|
-
|
2189
|
-
#def edit_pattern_(elm)
|
2190
|
-
#
|
2191
|
-
# elm.arguments.map.each do |name, attr|
|
2192
|
-
# if attr.changed then
|
2193
|
-
# @_attr_value = escape_regex(attr.value)
|
2194
|
-
# ##replace2regex(@_attr_value)
|
2195
|
-
# #@pattern_cc = '' << name << SET_ATTR_1
|
2196
|
-
# @pattern_cc = "#{attr.name}=\"[^\"]*\""
|
2197
|
-
# @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
2198
|
-
# #elm.pattern.gsub!(@pattern,'' << name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION)
|
2199
|
-
# elm.pattern.sub!(@pattern, "#{attr.name}=\"#{@_attr_value}\"")
|
2200
|
-
# elsif attr.removed then
|
2201
|
-
# @pattern_cc = '' << name << SET_ATTR_1
|
2202
|
-
# #@pattern_cc = "#{attr_name}=\"[^\"]*\""
|
2203
|
-
# @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
2204
|
-
# elm.pattern.gsub!(@pattern, EMPTY)
|
2205
|
-
# end
|
2206
|
-
# end
|
2207
|
-
#end
|
2208
|
-
#private :edit_pattern_
|
2214
|
+
private :edit_attributes_
|
2209
2215
|
|
2210
2216
|
#
|
2211
|
-
# 要素の属性値を取得する
|
2212
|
-
#
|
2217
|
+
# 要素の属性値を取得する
|
2213
2218
|
# @param [Meteor::Element] elm 要素
|
2214
2219
|
# @param [String] attr_name 属性名
|
2215
2220
|
# @return [String] 属性値
|
2216
2221
|
#
|
2217
|
-
def
|
2222
|
+
def get_attribute_value(elm,attr_name)
|
2218
2223
|
get_attribute_value_(elm,attr_name)
|
2219
2224
|
end
|
2220
|
-
private :
|
2225
|
+
private :get_attribute_value
|
2221
2226
|
|
2222
2227
|
def get_attribute_value_(elm,attr_name)
|
2223
2228
|
|
@@ -2235,27 +2240,36 @@ module Meteor
|
|
2235
2240
|
private :get_attribute_value_
|
2236
2241
|
|
2237
2242
|
#
|
2238
|
-
#
|
2239
|
-
#
|
2240
|
-
#
|
2241
|
-
#
|
2243
|
+
# @overload def attribute_map(elm,attr_map)
|
2244
|
+
# 属性マップをセットする
|
2245
|
+
# @param [Meteor::Element] elm 要素
|
2246
|
+
# @param [Meteor::AttributeMap] attrMap 属性マップ
|
2247
|
+
# @return [Meteor::Element] 要素
|
2248
|
+
# @overload def attribute_map(elm)
|
2249
|
+
# 属性マップを取得する
|
2250
|
+
# @param [Meteor::Element] elm 要素
|
2251
|
+
# @return [Meteor::AttributeMap] 属性マップ
|
2242
2252
|
#
|
2243
2253
|
def attribute_map(*args)
|
2244
2254
|
case args.length
|
2245
2255
|
when ONE
|
2246
|
-
|
2256
|
+
get_attribute_map(args[0])
|
2257
|
+
when TWO
|
2258
|
+
#if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(Meteor::AttributeMap) then
|
2259
|
+
args[0].document_sync = true
|
2260
|
+
set_attribute_map(args[0],args[1])
|
2261
|
+
#end
|
2247
2262
|
else
|
2248
2263
|
raise ArgumentError
|
2249
2264
|
end
|
2250
2265
|
end
|
2251
2266
|
|
2252
2267
|
#
|
2253
|
-
# 属性マップを取得する
|
2254
|
-
#
|
2268
|
+
# 属性マップを取得する
|
2255
2269
|
# @param [Meteor::Element] elm 要素
|
2256
2270
|
# @return [Meteor::AttributeMap] 属性マップ
|
2257
2271
|
#
|
2258
|
-
def
|
2272
|
+
def get_attribute_map(elm)
|
2259
2273
|
attrs = Meteor::AttributeMap.new
|
2260
2274
|
|
2261
2275
|
elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
|
@@ -2265,15 +2279,15 @@ module Meteor
|
|
2265
2279
|
|
2266
2280
|
attrs
|
2267
2281
|
end
|
2268
|
-
private :
|
2282
|
+
private :get_attribute_map
|
2269
2283
|
|
2270
2284
|
#
|
2271
|
-
#
|
2272
|
-
#
|
2285
|
+
# 要素の属性マップをセットする
|
2273
2286
|
# @param [Meteor::Element] elm 要素
|
2274
2287
|
# @param [Meteor::AttributeMap] attrMap 属性マップ
|
2288
|
+
# @return [Meteor::Element] 要素
|
2275
2289
|
#
|
2276
|
-
def
|
2290
|
+
def set_attribute_map(elm,attr_map)
|
2277
2291
|
if !elm.cx then
|
2278
2292
|
attr_map.map.each do |name, attr|
|
2279
2293
|
if attr_map.changed(name) then
|
@@ -2285,13 +2299,24 @@ module Meteor
|
|
2285
2299
|
end
|
2286
2300
|
elm
|
2287
2301
|
end
|
2288
|
-
private :
|
2302
|
+
private :set_attribute_map
|
2289
2303
|
|
2290
2304
|
#
|
2291
|
-
#
|
2292
|
-
#
|
2293
|
-
#
|
2294
|
-
#
|
2305
|
+
# @overload def content(elm,content,entity_ref=true)
|
2306
|
+
# 要素の内容をセットする
|
2307
|
+
# @param [Meteor::Element] elm 要素
|
2308
|
+
# @param [String] content 要素の内容
|
2309
|
+
# @param [true,false] entity_ref エンティティ参照フラグ
|
2310
|
+
# @return [Meteor::Element] 要素
|
2311
|
+
# @overload def content(elm,content)
|
2312
|
+
# 要素の内容をセットする
|
2313
|
+
# @param [Meteor::Element] elm 要素
|
2314
|
+
# @param [String] content 要素の内容
|
2315
|
+
# @return [Meteor::Element] 要素
|
2316
|
+
# @overload def content(elm)
|
2317
|
+
# 要素の内容を取得する
|
2318
|
+
# @param [Meteor::Element] elm 要素
|
2319
|
+
# @return [String] 内容
|
2295
2320
|
#
|
2296
2321
|
def content(*args)
|
2297
2322
|
case args.length
|
@@ -2304,7 +2329,7 @@ module Meteor
|
|
2304
2329
|
when TWO
|
2305
2330
|
#if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
2306
2331
|
args[0].document_sync = true
|
2307
|
-
|
2332
|
+
set_content_2(args[0],args[1])
|
2308
2333
|
#else
|
2309
2334
|
# raise ArgumentError
|
2310
2335
|
#end
|
@@ -2318,10 +2343,10 @@ module Meteor
|
|
2318
2343
|
|
2319
2344
|
#
|
2320
2345
|
# 要素の内容をセットする
|
2321
|
-
#
|
2322
2346
|
# @param [Meteor::Element] elm 要素
|
2323
2347
|
# @param [String] content 要素の内容
|
2324
|
-
# @param [
|
2348
|
+
# @param [true,false] entityRef エンティティ参照フラグ
|
2349
|
+
# @return [Meteor::Element] 要素
|
2325
2350
|
#
|
2326
2351
|
def set_content_3(elm,content,entity_ref=true)
|
2327
2352
|
|
@@ -2334,22 +2359,22 @@ module Meteor
|
|
2334
2359
|
private :set_content_3
|
2335
2360
|
|
2336
2361
|
#
|
2337
|
-
#
|
2338
|
-
#
|
2362
|
+
# 要素の内容をセットする
|
2339
2363
|
# @param [Meteor::Element] elm 要素
|
2340
2364
|
# @param [String] content 要素の内容
|
2365
|
+
# @return [Meteor::Element] 要素
|
2341
2366
|
#
|
2342
|
-
def
|
2367
|
+
def set_content_2(elm,content)
|
2343
2368
|
#set_content_3(elm, content)
|
2344
2369
|
elm.mixed_content = escape_content(content,elm)
|
2345
2370
|
elm
|
2346
2371
|
end
|
2347
|
-
private :
|
2372
|
+
private :set_content_2
|
2348
2373
|
|
2349
2374
|
#
|
2350
|
-
# 要素の内容を取得する
|
2351
|
-
#
|
2375
|
+
# 要素の内容を取得する
|
2352
2376
|
# @param [Meteor::Element] elm 要素
|
2377
|
+
# @return [String] 内容
|
2353
2378
|
#
|
2354
2379
|
def get_content_1(elm)
|
2355
2380
|
if !elm.cx then
|
@@ -2366,27 +2391,11 @@ module Meteor
|
|
2366
2391
|
|
2367
2392
|
#
|
2368
2393
|
# 要素の属性を消す
|
2369
|
-
#
|
2370
|
-
# @param [Array] args 引数配列
|
2371
|
-
#
|
2372
|
-
def remove_attribute(*args)
|
2373
|
-
case args.length
|
2374
|
-
#when ONE
|
2375
|
-
# remove_attribute_1(args[0])
|
2376
|
-
when TWO
|
2377
|
-
remove_attribute_2(args[0],args[1])
|
2378
|
-
else
|
2379
|
-
raise ArgumentError
|
2380
|
-
end
|
2381
|
-
end
|
2382
|
-
|
2383
|
-
#
|
2384
|
-
# 要素の属性を消す
|
2385
|
-
#
|
2386
2394
|
# @param [Meteor::Element] elm 要素
|
2387
2395
|
# @param [String] attr_name 属性名
|
2396
|
+
# @return [Meteor::Element] 要素
|
2388
2397
|
#
|
2389
|
-
def
|
2398
|
+
def remove_attribute(elm,attr_name)
|
2390
2399
|
if !elm.cx then
|
2391
2400
|
|
2392
2401
|
elm.document_sync = true
|
@@ -2397,12 +2406,11 @@ module Meteor
|
|
2397
2406
|
# elm.arguments.delete(attr_name)
|
2398
2407
|
# end
|
2399
2408
|
#end
|
2400
|
-
|
2401
2409
|
end
|
2402
2410
|
|
2403
2411
|
elm
|
2404
2412
|
end
|
2405
|
-
private :
|
2413
|
+
private :remove_attribute
|
2406
2414
|
|
2407
2415
|
def remove_attributes_(elm,attr_name)
|
2408
2416
|
#属性検索用パターン
|
@@ -2410,23 +2418,27 @@ module Meteor
|
|
2410
2418
|
#属性の置換
|
2411
2419
|
elm.attributes.sub!(@pattern,EMPTY)
|
2412
2420
|
end
|
2413
|
-
private :remove_attributes_
|
2421
|
+
private :remove_attributes_
|
2414
2422
|
|
2415
2423
|
#
|
2416
2424
|
# 要素を消す
|
2417
|
-
#
|
2418
2425
|
# @param [Meteor::Element] elm 要素
|
2419
2426
|
#
|
2420
2427
|
def remove_element(elm)
|
2421
2428
|
replace(elm,EMPTY)
|
2422
2429
|
elm.usable = false
|
2430
|
+
nil
|
2423
2431
|
end
|
2424
2432
|
|
2425
2433
|
#
|
2426
2434
|
# CX(コメント拡張)タグを取得する
|
2427
|
-
#
|
2428
|
-
#
|
2429
|
-
#
|
2435
|
+
# @overload def cxtag(elm_name,id)
|
2436
|
+
# @param [String] elm_name 要素名
|
2437
|
+
# @param [String] id ID属性値
|
2438
|
+
# @return [Meteor::Element] 要素
|
2439
|
+
# @overload def cxtag(id)
|
2440
|
+
# @param [String] id ID属性値
|
2441
|
+
# @return [Meteor::Element] 要素
|
2430
2442
|
#
|
2431
2443
|
def cxtag(*args)
|
2432
2444
|
case args.length
|
@@ -2447,7 +2459,6 @@ module Meteor
|
|
2447
2459
|
|
2448
2460
|
#
|
2449
2461
|
# 要素名とID属性で検索し、CX(コメント拡張)タグを取得する
|
2450
|
-
#
|
2451
2462
|
# @param [String] elm_name 要素名
|
2452
2463
|
# @param [String] id ID属性値
|
2453
2464
|
# @return [Meteor::Element] 要素
|
@@ -2491,7 +2502,6 @@ module Meteor
|
|
2491
2502
|
|
2492
2503
|
#
|
2493
2504
|
# ID属性で検索し、CX(コメント拡張)タグを取得する
|
2494
|
-
#
|
2495
2505
|
# @param [String] id ID属性値
|
2496
2506
|
# @return [Meteor::Element] 要素
|
2497
2507
|
#
|
@@ -2516,7 +2526,6 @@ module Meteor
|
|
2516
2526
|
|
2517
2527
|
#
|
2518
2528
|
# 要素を置換する
|
2519
|
-
#
|
2520
2529
|
# @param [Meteor::Element] elm 要素
|
2521
2530
|
# @param [String] replaceDocument 置換文字列
|
2522
2531
|
#
|
@@ -2554,12 +2563,56 @@ module Meteor
|
|
2554
2563
|
end
|
2555
2564
|
protected :reflect
|
2556
2565
|
|
2566
|
+
def edit_document_1(elm)
|
2567
|
+
edit_document_2(elm,TAG_CLOSE3)
|
2568
|
+
end
|
2569
|
+
private :edit_document_1
|
2570
|
+
|
2571
|
+
def edit_document_2(elm,closer)
|
2572
|
+
if !elm.cx then
|
2573
|
+
@_attributes = elm.attributes
|
2574
|
+
#replace2regex(@_attributes)
|
2575
|
+
|
2576
|
+
if elm.empty then
|
2577
|
+
#内容あり要素の場合
|
2578
|
+
@_content = elm.mixed_content
|
2579
|
+
##replace2regex(@_content)
|
2580
|
+
#if elm.origin then
|
2581
|
+
# replace4regex(@_content)
|
2582
|
+
#else
|
2583
|
+
# replace2regex(@_content)
|
2584
|
+
#end
|
2585
|
+
|
2586
|
+
elm.document = '' << TAG_OPEN << elm.name << @_attributes << TAG_CLOSE << @_content << TAG_OPEN3 << elm.name << TAG_CLOSE
|
2587
|
+
#elm.document = "<#{elm.name}#{@_attributes}>#{@_content}</#{elm.name}>"
|
2588
|
+
else
|
2589
|
+
#空要素の場合
|
2590
|
+
elm.document = '' << TAG_OPEN << elm.name << @_attributes << closer
|
2591
|
+
end
|
2592
|
+
else
|
2593
|
+
@_content = elm.mixed_content
|
2594
|
+
#if elm.origin then
|
2595
|
+
# replace4regex(@_content)
|
2596
|
+
#else
|
2597
|
+
# replace2regex(@_content)
|
2598
|
+
#end
|
2599
|
+
|
2600
|
+
#elm.document = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2
|
2601
|
+
#elm.document << @_content << SET_CX_3 << elm.name << SET_CX_4
|
2602
|
+
elm.document = "<!-- @#{elm.name} #{elm.attributes}-->#{@_content}<!-- /@#{elm.name} -->"
|
2603
|
+
end
|
2604
|
+
|
2605
|
+
#タグ置換
|
2606
|
+
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
2607
|
+
@root.document.sub!(@pattern,elm.document)
|
2608
|
+
end
|
2609
|
+
private :edit_document_2
|
2610
|
+
|
2557
2611
|
#
|
2558
|
-
#
|
2612
|
+
# 反映する
|
2559
2613
|
#
|
2560
2614
|
def flush
|
2561
|
-
|
2562
|
-
#puts @root.document
|
2615
|
+
|
2563
2616
|
if @root.element then
|
2564
2617
|
if @root.element.origin.mono then
|
2565
2618
|
if @root.element.origin.cx then
|
@@ -2678,20 +2731,6 @@ module Meteor
|
|
2678
2731
|
end
|
2679
2732
|
private :escape_regex
|
2680
2733
|
|
2681
|
-
#def replace2regex(str)
|
2682
|
-
# #if str.include?(EN_1) then
|
2683
|
-
# # str.gsub!(@@pattern_sub_regex1,SUB_REGEX2)
|
2684
|
-
# #end
|
2685
|
-
#end
|
2686
|
-
#private :replace2regex
|
2687
|
-
|
2688
|
-
#def replace4regex(str)
|
2689
|
-
# #if str.include?(EN_1) then
|
2690
|
-
# # str.gsub!(@@pattern_sub_regex1,SUB_REGEX3)
|
2691
|
-
# #end
|
2692
|
-
#end
|
2693
|
-
#private :replace4regex
|
2694
|
-
|
2695
2734
|
#
|
2696
2735
|
# @param [String] content 入力文字列
|
2697
2736
|
# @return [String] 出力文字列
|
@@ -2747,7 +2786,6 @@ module Meteor
|
|
2747
2786
|
end
|
2748
2787
|
private :is_match
|
2749
2788
|
|
2750
|
-
|
2751
2789
|
def is_match_r(regex,str)
|
2752
2790
|
if regex.match(str.downcase) then
|
2753
2791
|
true
|
@@ -2778,19 +2816,53 @@ module Meteor
|
|
2778
2816
|
private :is_match_s
|
2779
2817
|
|
2780
2818
|
def create(pif)
|
2781
|
-
|
2819
|
+
case pif.doc_type
|
2820
|
+
when Parser::HTML then
|
2782
2821
|
pif = Meteor::Core::Html::ParserImpl.new
|
2783
|
-
|
2822
|
+
when Parser::XHTML then
|
2784
2823
|
pif = Meteor::Core::Xhtml::ParserImpl.new
|
2785
|
-
|
2824
|
+
when Parser::XML then
|
2786
2825
|
pif = Meteor::Core::Xml::ParserImpl.new
|
2787
2826
|
else
|
2788
2827
|
pif = nil
|
2789
2828
|
end
|
2790
|
-
|
2791
2829
|
end
|
2792
2830
|
private :create
|
2793
2831
|
|
2832
|
+
#def edit_pattern_(elm)
|
2833
|
+
#
|
2834
|
+
# elm.arguments.map.each do |name, attr|
|
2835
|
+
# if attr.changed then
|
2836
|
+
# @_attr_value = escape_regex(attr.value)
|
2837
|
+
# ##replace2regex(@_attr_value)
|
2838
|
+
# #@pattern_cc = '' << name << SET_ATTR_1
|
2839
|
+
# @pattern_cc = "#{attr.name}=\"[^\"]*\""
|
2840
|
+
# @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
2841
|
+
# #elm.pattern.gsub!(@pattern,'' << name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION)
|
2842
|
+
# elm.pattern.sub!(@pattern, "#{attr.name}=\"#{@_attr_value}\"")
|
2843
|
+
# elsif attr.removed then
|
2844
|
+
# @pattern_cc = '' << name << SET_ATTR_1
|
2845
|
+
# #@pattern_cc = "#{attr_name}=\"[^\"]*\""
|
2846
|
+
# @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
2847
|
+
# elm.pattern.gsub!(@pattern, EMPTY)
|
2848
|
+
# end
|
2849
|
+
# end
|
2850
|
+
#end
|
2851
|
+
#private :edit_pattern_
|
2852
|
+
|
2853
|
+
#def replace2regex(str)
|
2854
|
+
# #if str.include?(EN_1) then
|
2855
|
+
# # str.gsub!(@@pattern_sub_regex1,SUB_REGEX2)
|
2856
|
+
# #end
|
2857
|
+
#end
|
2858
|
+
#private :replace2regex
|
2859
|
+
|
2860
|
+
#def replace4regex(str)
|
2861
|
+
# #if str.include?(EN_1) then
|
2862
|
+
# # str.gsub!(@@pattern_sub_regex1,SUB_REGEX3)
|
2863
|
+
# #end
|
2864
|
+
#end
|
2865
|
+
#private :replace4regex
|
2794
2866
|
end
|
2795
2867
|
|
2796
2868
|
module Util
|
@@ -2807,83 +2879,108 @@ module Meteor
|
|
2807
2879
|
def initialize
|
2808
2880
|
end
|
2809
2881
|
|
2882
|
+
|
2883
|
+
#
|
2884
|
+
# パターンを取得する
|
2885
|
+
# @overload def get(regex)
|
2886
|
+
# @param [String] regex 正規表現
|
2887
|
+
# @return [Regexp] パターン
|
2888
|
+
# @overload def get(regex,option)
|
2889
|
+
# @param [String] regex 正規表現
|
2890
|
+
# @param [Fixnum] option オプション
|
2891
|
+
# @return [Regexp] パターン
|
2892
|
+
#
|
2810
2893
|
def self.get(*args)
|
2811
2894
|
case args.length
|
2812
2895
|
when ONE
|
2813
|
-
get_1(args[0])
|
2896
|
+
#get_1(args[0])
|
2897
|
+
if !@@regex_cache[args[0].to_sym] then
|
2898
|
+
#if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2899
|
+
@@regex_cache[args[0].to_sym] = Regexp.new(args[0], Regexp::MULTILINE)
|
2900
|
+
#else
|
2901
|
+
# @@regex_cache[args[0].to_sym] = Regexp.new(args[0], Regexp::MULTILINE,E_UTF8)
|
2902
|
+
#end
|
2903
|
+
end
|
2904
|
+
@@regex_cache[args[0].to_sym]
|
2814
2905
|
when TWO
|
2815
|
-
get_2(args[0], args[1])
|
2906
|
+
#get_2(args[0], args[1])
|
2907
|
+
if !@@regex_cache[args[0].to_sym] then
|
2908
|
+
#if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2909
|
+
@@regex_cache[args[0].to_sym] = Regexp.new(args[0], args[1])
|
2910
|
+
#else
|
2911
|
+
# @@regex_cache[args[0].to_sym] = Regexp.new(args[0], args[1],E_UTF8)
|
2912
|
+
#end
|
2913
|
+
end
|
2914
|
+
@@regex_cache[args[0].to_sym]
|
2816
2915
|
else
|
2817
2916
|
raise ArgumentError
|
2818
2917
|
end
|
2819
2918
|
end
|
2820
2919
|
|
2920
|
+
##
|
2921
|
+
## パターンを取得する
|
2922
|
+
## @param [String] regex 正規表現
|
2923
|
+
## @return [Regexp] パターン
|
2924
|
+
##
|
2925
|
+
#def self.get_1(regex)
|
2926
|
+
# ##pattern = @@regex_cache[regex]
|
2927
|
+
# ##
|
2928
|
+
# ##if pattern == nil then
|
2929
|
+
# #if regex.kind_of?(String) then
|
2930
|
+
# if !@@regex_cache[regex.to_sym] then
|
2931
|
+
# #pattern = Regexp.new(regex)
|
2932
|
+
# #@@regex_cache[regex] = pattern
|
2933
|
+
# if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2934
|
+
# @@regex_cache[regex.to_sym] = Regexp.new(regex, Regexp::MULTILINE)
|
2935
|
+
# else
|
2936
|
+
# @@regex_cache[regex.to_sym] = Regexp.new(regex, Regexp::MULTILINE,E_UTF8)
|
2937
|
+
# end
|
2938
|
+
# end
|
2821
2939
|
#
|
2822
|
-
#
|
2823
|
-
#
|
2824
|
-
#
|
2825
|
-
#
|
2826
|
-
|
2827
|
-
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2831
|
-
|
2832
|
-
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
else
|
2837
|
-
@@regex_cache[regex.to_sym] = Regexp.new(regex, Regexp::MULTILINE,E_UTF8)
|
2838
|
-
end
|
2839
|
-
end
|
2840
|
-
|
2841
|
-
#return pattern
|
2842
|
-
@@regex_cache[regex.to_sym]
|
2843
|
-
elsif regex.kind_of?(Symbol) then
|
2844
|
-
if !@@regex_cache[regex] then
|
2845
|
-
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2846
|
-
@@regex_cache[regex] = Regexp.new(regex.to_s, Regexp::MULTILINE)
|
2847
|
-
else
|
2848
|
-
@@regex_cache[regex] = Regexp.new(regex.to_s, Regexp::MULTILINE,E_UTF8)
|
2849
|
-
end
|
2850
|
-
end
|
2851
|
-
|
2852
|
-
@@regex_cache[regex]
|
2853
|
-
end
|
2854
|
-
end
|
2940
|
+
# #return pattern
|
2941
|
+
# @@regex_cache[regex.to_sym]
|
2942
|
+
# ##elsif regex.kind_of?(Symbol) then
|
2943
|
+
# ## if !@@regex_cache[regex] then
|
2944
|
+
# ## if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2945
|
+
# ## @@regex_cache[regex.object_id] = Regexp.new(regex.to_s, Regexp::MULTILINE)
|
2946
|
+
# ## else
|
2947
|
+
# ## @@regex_cache[regex.object_id] = Regexp.new(regex.to_s, Regexp::MULTILINE,E_UTF8)
|
2948
|
+
# ## end
|
2949
|
+
# ## end
|
2950
|
+
# ##
|
2951
|
+
# ## @@regex_cache[regex]
|
2952
|
+
# #end
|
2953
|
+
#end
|
2855
2954
|
|
2955
|
+
##
|
2956
|
+
## パターンを取得する
|
2957
|
+
## @param [String] regex 正規表現
|
2958
|
+
## @param [Fixnum] option オプション
|
2959
|
+
## @return [Regexp] パターン
|
2960
|
+
##
|
2961
|
+
#def self.get_2(regex, option)
|
2962
|
+
# ##pattern = @@regex_cache[regex]
|
2963
|
+
# ##
|
2964
|
+
# ##if pattern == nil then
|
2965
|
+
# #if regex.kind_of?(String) then
|
2966
|
+
# if !@@regex_cache[regex.to_sym] then
|
2967
|
+
# #pattern = Regexp.new(regex)
|
2968
|
+
# #@@regex_cache[regex] = pattern
|
2969
|
+
# @@regex_cache[regex.to_sym] = Regexp.new(regex, option,E_UTF8)
|
2970
|
+
# end
|
2856
2971
|
#
|
2857
|
-
#
|
2858
|
-
#
|
2859
|
-
#
|
2860
|
-
#
|
2861
|
-
|
2862
|
-
|
2863
|
-
|
2864
|
-
|
2865
|
-
|
2866
|
-
|
2867
|
-
#pattern = Regexp.new(regex)
|
2868
|
-
#@@regex_cache[regex] = pattern
|
2869
|
-
@@regex_cache[regex.to_sym] = Regexp.new(regex, option,E_UTF8)
|
2870
|
-
end
|
2871
|
-
|
2872
|
-
#return pattern
|
2873
|
-
@@regex_cache[regex.to_sym]
|
2874
|
-
elsif regex.kind_of?(Symbol) then
|
2875
|
-
if !@@regex_cache[regex] then
|
2876
|
-
@@regex_cache[regex] = Regexp.new(regex.to_s, option,E_UTF8)
|
2877
|
-
end
|
2878
|
-
|
2879
|
-
@@regex_cache[regex]
|
2880
|
-
end
|
2881
|
-
end
|
2972
|
+
# #return pattern
|
2973
|
+
# @@regex_cache[regex.to_sym]
|
2974
|
+
# ##elsif regex.kind_of?(Symbol) then
|
2975
|
+
# ## if !@@regex_cache[regex] then
|
2976
|
+
# ## @@regex_cache[regex] = Regexp.new(regex.to_s, option,E_UTF8)
|
2977
|
+
# ## end
|
2978
|
+
# ##
|
2979
|
+
# ## @@regex_cache[regex]
|
2980
|
+
# #end
|
2981
|
+
#end
|
2882
2982
|
end
|
2883
2983
|
|
2884
|
-
|
2885
|
-
#if RUBY_VERSION < RUBY_VERSION_1_9_0 then
|
2886
|
-
|
2887
2984
|
class OrderHash < Hash
|
2888
2985
|
|
2889
2986
|
def initialize
|
@@ -2962,9 +3059,7 @@ module Meteor
|
|
2962
3059
|
end
|
2963
3060
|
return hash_tmp
|
2964
3061
|
end
|
2965
|
-
end
|
2966
|
-
|
2967
|
-
#end
|
3062
|
+
end
|
2968
3063
|
|
2969
3064
|
end
|
2970
3065
|
|
@@ -3094,46 +3189,51 @@ module Meteor
|
|
3094
3189
|
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
3095
3190
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
3096
3191
|
@@pattern_get_attrs_map2 = Regexp.new(GET_ATTRS_MAP2)
|
3192
|
+
|
3193
|
+
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
3194
|
+
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
3097
3195
|
else
|
3098
|
-
@@pattern_selected_m = Regexp.new(SELECTED_M
|
3099
|
-
@@pattern_selected_r = Regexp.new(SELECTED_R
|
3100
|
-
@@pattern_checked_m = Regexp.new(CHECKED_M
|
3101
|
-
@@pattern_checked_r = Regexp.new(CHECKED_R
|
3102
|
-
@@pattern_disabled_m = Regexp.new(DISABLED_M
|
3103
|
-
@@pattern_disabled_r = Regexp.new(DISABLED_R
|
3104
|
-
@@pattern_readonly_m = Regexp.new(READONLY_M
|
3105
|
-
@@pattern_readonly_r = Regexp.new(READONLY_R
|
3106
|
-
@@pattern_multiple_m = Regexp.new(MULTIPLE_M
|
3107
|
-
@@pattern_multiple_r = Regexp.new(MULTIPLE_R
|
3108
|
-
|
3109
|
-
@@pattern_and_1 = Regexp.new(AND_1
|
3110
|
-
@@pattern_lt_1 = Regexp.new(LT_1
|
3111
|
-
@@pattern_gt_1 = Regexp.new(GT_1
|
3112
|
-
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION
|
3113
|
-
@@pattern_space_1 = Regexp.new(SPACE
|
3114
|
-
@@pattern_br_1 = Regexp.new(BR_1
|
3115
|
-
@@pattern_lt_2 = Regexp.new(LT_2
|
3116
|
-
@@pattern_gt_2 = Regexp.new(GT_2
|
3117
|
-
@@pattern_dq_2 = Regexp.new(QO_2
|
3118
|
-
@@pattern_space_2 = Regexp.new(NBSP_2
|
3119
|
-
@@pattern_and_2 = Regexp.new(AND_2
|
3120
|
-
@@pattern_br_2 = Regexp.new(BR_2
|
3121
|
-
|
3122
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE
|
3123
|
-
@@pattern_set_mono1 = Regexp.new(SET_MONO_1
|
3124
|
-
@@pattern_get_attrs_map2 = Regexp.new(GET_ATTRS_MAP2
|
3125
|
-
end
|
3196
|
+
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
3197
|
+
@@pattern_selected_r = Regexp.new(SELECTED_R)
|
3198
|
+
@@pattern_checked_m = Regexp.new(CHECKED_M)
|
3199
|
+
@@pattern_checked_r = Regexp.new(CHECKED_R)
|
3200
|
+
@@pattern_disabled_m = Regexp.new(DISABLED_M)
|
3201
|
+
@@pattern_disabled_r = Regexp.new(DISABLED_R)
|
3202
|
+
@@pattern_readonly_m = Regexp.new(READONLY_M)
|
3203
|
+
@@pattern_readonly_r = Regexp.new(READONLY_R)
|
3204
|
+
@@pattern_multiple_m = Regexp.new(MULTIPLE_M)
|
3205
|
+
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
3206
|
+
|
3207
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
3208
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
3209
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
3210
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
3211
|
+
@@pattern_space_1 = Regexp.new(SPACE)
|
3212
|
+
@@pattern_br_1 = Regexp.new(BR_1)
|
3213
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
3214
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
3215
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
3216
|
+
@@pattern_space_2 = Regexp.new(NBSP_2)
|
3217
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
3218
|
+
@@pattern_br_2 = Regexp.new(BR_2)
|
3219
|
+
|
3220
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
3221
|
+
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
3222
|
+
@@pattern_get_attrs_map2 = Regexp.new(GET_ATTRS_MAP2)
|
3126
3223
|
|
3127
|
-
|
3128
|
-
|
3224
|
+
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
3225
|
+
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
3226
|
+
end
|
3129
3227
|
|
3130
3228
|
#
|
3131
3229
|
# イニシャライザ
|
3132
|
-
#
|
3133
|
-
# @
|
3230
|
+
# @overload def initialize
|
3231
|
+
# @overload def initialize(ps)
|
3232
|
+
# @param [Meteor::Parser] ps パーサ
|
3134
3233
|
#
|
3135
3234
|
def initialize(*args)
|
3136
|
-
super(
|
3235
|
+
super()
|
3236
|
+
@doc_type = Parser::HTML
|
3137
3237
|
case args.length
|
3138
3238
|
when ZERO
|
3139
3239
|
initialize_0
|
@@ -3160,13 +3260,11 @@ module Meteor
|
|
3160
3260
|
@root.hook_document = String.new(ps.root_element.hook_document)
|
3161
3261
|
@root.content_type = String.new(ps.content_type);
|
3162
3262
|
@root.kaigyo_code = ps.root_element.kaigyo_code
|
3163
|
-
@doc_type = ps.doc_type
|
3164
3263
|
end
|
3165
3264
|
private :initialize_1
|
3166
3265
|
|
3167
3266
|
#
|
3168
|
-
# ドキュメントをパーサにセットする
|
3169
|
-
#
|
3267
|
+
# ドキュメントをパーサにセットする
|
3170
3268
|
# @param [String] document ドキュメント
|
3171
3269
|
#
|
3172
3270
|
def parse(document)
|
@@ -3175,8 +3273,7 @@ module Meteor
|
|
3175
3273
|
end
|
3176
3274
|
|
3177
3275
|
#
|
3178
|
-
# ファイルを読み込み、パーサにセットする
|
3179
|
-
#
|
3276
|
+
# ファイルを読み込み、パーサにセットする
|
3180
3277
|
# @param [String] filePath ファイルパス
|
3181
3278
|
# @param [String] encoding エンコーディング
|
3182
3279
|
#
|
@@ -3198,9 +3295,9 @@ module Meteor
|
|
3198
3295
|
end
|
3199
3296
|
private :analyze_ml
|
3200
3297
|
|
3298
|
+
#
|
3201
3299
|
# コンテントタイプを取得する
|
3202
|
-
#
|
3203
|
-
# @return [Streing]コンテントタイプ
|
3300
|
+
# @return [String]コンテントタイプ
|
3204
3301
|
#
|
3205
3302
|
def content_type
|
3206
3303
|
@root.content_type
|
@@ -3249,7 +3346,6 @@ module Meteor
|
|
3249
3346
|
|
3250
3347
|
#
|
3251
3348
|
# 要素名で検索し、要素を取得する
|
3252
|
-
#
|
3253
3349
|
# @param [String] elm_name 要素名
|
3254
3350
|
# @return [Meteor::Element] 要素
|
3255
3351
|
#
|
@@ -3303,7 +3399,6 @@ module Meteor
|
|
3303
3399
|
|
3304
3400
|
#
|
3305
3401
|
# 要素名、属性(属性名="属性値")で検索し、要素を取得する
|
3306
|
-
#
|
3307
3402
|
# @param [String] elm_name 要素名
|
3308
3403
|
# @param [String] attr_name 属性名
|
3309
3404
|
# @param [String] attr_value 属性値
|
@@ -3366,8 +3461,7 @@ module Meteor
|
|
3366
3461
|
private :element_without_3
|
3367
3462
|
|
3368
3463
|
#
|
3369
|
-
# 属性(属性名="属性値")で検索し、要素を取得する
|
3370
|
-
#
|
3464
|
+
# 属性(属性名="属性値")で検索し、要素を取得する
|
3371
3465
|
# @param [String] attr_name 属性名
|
3372
3466
|
# @param [String] attr_value 属性値
|
3373
3467
|
# @return [Meteor::Element] 要素
|
@@ -3394,13 +3488,12 @@ module Meteor
|
|
3394
3488
|
private :element_2
|
3395
3489
|
|
3396
3490
|
#
|
3397
|
-
# 要素名と属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
3398
|
-
#
|
3491
|
+
# 要素名と属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
3399
3492
|
# @param [String] elm_name 要素名
|
3400
|
-
# @param attr_name1 属性名1
|
3401
|
-
# @param attr_value1 属性値1
|
3402
|
-
# @param attr_name2 属性名2
|
3403
|
-
# @param attr_value2 属性値2
|
3493
|
+
# @param [String] attr_name1 属性名1
|
3494
|
+
# @param [String] attr_value1 属性値1
|
3495
|
+
# @param [String] attr_name2 属性名2
|
3496
|
+
# @param [String] attr_value2 属性値2
|
3404
3497
|
# @return [Meteor::Element] 要素
|
3405
3498
|
#
|
3406
3499
|
def element_5(elm_name,attr_name1,attr_value1,attr_name2,attr_value2)
|
@@ -3556,20 +3649,20 @@ module Meteor
|
|
3556
3649
|
|
3557
3650
|
def get_attribute_value_(elm,attr_name)
|
3558
3651
|
if is_match(SELECTED, attr_name) && is_match(OPTION,elm.name) then
|
3559
|
-
|
3560
|
-
#
|
3652
|
+
get_attribute_value_r(elm,@@pattern_selected_m)
|
3653
|
+
#get_attribute_value_r(elm,SELECTED_M)
|
3561
3654
|
elsif is_match(MULTIPLE, attr_name) && is_match(SELECT,elm.name)
|
3562
|
-
|
3563
|
-
#
|
3655
|
+
get_attribute_value_r(elm,@@pattern_multiple_m)
|
3656
|
+
#get_attribute_value_r(elm,MULTIPLE_M)
|
3564
3657
|
elsif is_match(DISABLED, attr_name) && is_match(DISABLE_ELEMENT, elm.name) then
|
3565
|
-
|
3566
|
-
#
|
3658
|
+
get_attribute_value_r(elm,@@pattern_disabled_m)
|
3659
|
+
#get_attribute_value_r(elm,DISABLED_M)
|
3567
3660
|
elsif is_match(CHECKED, attr_name) && is_match(INPUT,elm.name) && is_match(RADIO, get_type(elm)) then
|
3568
|
-
|
3569
|
-
#
|
3661
|
+
get_attribute_value_r(elm,@@pattern_checked_m)
|
3662
|
+
#get_attribute_value_r(elm,CHECKED_M)
|
3570
3663
|
elsif is_match(READONLY, attr_name) && (is_match(TEXTAREA,elm.name) || (is_match(INPUT,elm.name) && is_match(READONLY_TYPE, get_type(elm)))) then
|
3571
|
-
|
3572
|
-
#
|
3664
|
+
get_attribute_value_r(elm,@@pattern_readonly_m)
|
3665
|
+
#get_attribute_value_r(elm,READONLY_M)
|
3573
3666
|
else
|
3574
3667
|
super(elm,attr_name)
|
3575
3668
|
end
|
@@ -3587,7 +3680,7 @@ module Meteor
|
|
3587
3680
|
end
|
3588
3681
|
private :get_type
|
3589
3682
|
|
3590
|
-
def
|
3683
|
+
def get_attribute_value_r(elm,match_p)
|
3591
3684
|
|
3592
3685
|
@res = match_p.match(elm.attributes)
|
3593
3686
|
|
@@ -3597,7 +3690,7 @@ module Meteor
|
|
3597
3690
|
FALSE
|
3598
3691
|
end
|
3599
3692
|
end
|
3600
|
-
private :
|
3693
|
+
private :get_attribute_value_r
|
3601
3694
|
|
3602
3695
|
#
|
3603
3696
|
# 要素の属性マップを取得する
|
@@ -3605,7 +3698,7 @@ module Meteor
|
|
3605
3698
|
# @param [Meteor::Element] elm 要素
|
3606
3699
|
# @return [Meteor::AttributeMap] 属性マップ
|
3607
3700
|
#
|
3608
|
-
def
|
3701
|
+
def get_attribute_map(elm)
|
3609
3702
|
attrs = Meteor::AttributeMap.new
|
3610
3703
|
|
3611
3704
|
elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
|
@@ -3620,9 +3713,9 @@ module Meteor
|
|
3620
3713
|
|
3621
3714
|
attrs
|
3622
3715
|
end
|
3623
|
-
private :
|
3716
|
+
private :get_attribute_map
|
3624
3717
|
|
3625
|
-
def
|
3718
|
+
def remove_attribute_(elm,attr_name)
|
3626
3719
|
#検索対象属性の論理型是非判定
|
3627
3720
|
if !is_match(ATTR_LOGIC,attr_name) then
|
3628
3721
|
#属性検索用パターン
|
@@ -3891,51 +3984,57 @@ module Meteor
|
|
3891
3984
|
|
3892
3985
|
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
3893
3986
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
3987
|
+
|
3988
|
+
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
3989
|
+
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
3894
3990
|
else
|
3895
|
-
@@pattern_selected_m = Regexp.new(SELECTED_M
|
3896
|
-
@@pattern_selected_m1 = Regexp.new(SELECTED_M1
|
3897
|
-
@@pattern_selected_r = Regexp.new(SELECTED_R
|
3898
|
-
@@pattern_checked_m = Regexp.new(CHECKED_M
|
3899
|
-
@@pattern_checked_m1 = Regexp.new(CHECKED_M1
|
3900
|
-
@@pattern_checked_r = Regexp.new(CHECKED_R
|
3901
|
-
@@pattern_disabled_m = Regexp.new(DISABLED_M
|
3902
|
-
@@pattern_disabled_m1 = Regexp.new(DISABLED_M1
|
3903
|
-
@@pattern_disabled_r = Regexp.new(DISABLED_R
|
3904
|
-
@@pattern_readonly_m = Regexp.new(READONLY_M
|
3905
|
-
@@pattern_readonly_m1 = Regexp.new(READONLY_M1
|
3906
|
-
@@pattern_readonly_r = Regexp.new(READONLY_R
|
3907
|
-
@@pattern_multiple_m = Regexp.new(MULTIPLE_M
|
3908
|
-
@@pattern_multiple_m1 = Regexp.new(MULTIPLE_M1
|
3909
|
-
@@pattern_multiple_r = Regexp.new(MULTIPLE_R
|
3910
|
-
|
3911
|
-
@@pattern_and_1 = Regexp.new(AND_1,nil,E_UTF8)
|
3912
|
-
@@pattern_lt_1 = Regexp.new(LT_1,nil,E_UTF8)
|
3913
|
-
@@pattern_gt_1 = Regexp.new(GT_1,nil,E_UTF8)
|
3914
|
-
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION,nil,E_UTF8)
|
3915
|
-
@@pattern_ap_1 = Regexp.new(AP_1,nil,E_UTF8)
|
3916
|
-
@@pattern_space_1 = Regexp.new(SPACE,nil,E_UTF8)
|
3917
|
-
@@pattern_br_1 = Regexp.new(BR_1,nil,E_UTF8)
|
3918
|
-
@@pattern_lt_2 = Regexp.new(LT_2,nil,E_UTF8)
|
3919
|
-
@@pattern_gt_2 = Regexp.new(GT_2,nil,E_UTF8)
|
3920
|
-
@@pattern_dq_2 = Regexp.new(QO_2,nil,E_UTF8)
|
3921
|
-
@@pattern_ap_2 = Regexp.new(AP_2,nil,E_UTF8)
|
3922
|
-
@@pattern_space_2 = Regexp.new(NBSP_2,nil,E_UTF8)
|
3923
|
-
@@pattern_and_2 = Regexp.new(AND_2,nil,E_UTF8)
|
3924
|
-
@@pattern_br_2 = Regexp.new(BR_3,nil,E_UTF8)
|
3925
|
-
|
3926
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE,nil,E_UTF8)
|
3927
|
-
@@pattern_set_mono1 = Regexp.new(SET_MONO_1,nil,E_UTF8)
|
3928
|
-
end
|
3991
|
+
@@pattern_selected_m = Regexp.new(SELECTED_M)
|
3992
|
+
@@pattern_selected_m1 = Regexp.new(SELECTED_M1)
|
3993
|
+
@@pattern_selected_r = Regexp.new(SELECTED_R)
|
3994
|
+
@@pattern_checked_m = Regexp.new(CHECKED_M)
|
3995
|
+
@@pattern_checked_m1 = Regexp.new(CHECKED_M1)
|
3996
|
+
@@pattern_checked_r = Regexp.new(CHECKED_R)
|
3997
|
+
@@pattern_disabled_m = Regexp.new(DISABLED_M)
|
3998
|
+
@@pattern_disabled_m1 = Regexp.new(DISABLED_M1)
|
3999
|
+
@@pattern_disabled_r = Regexp.new(DISABLED_R)
|
4000
|
+
@@pattern_readonly_m = Regexp.new(READONLY_M)
|
4001
|
+
@@pattern_readonly_m1 = Regexp.new(READONLY_M1)
|
4002
|
+
@@pattern_readonly_r = Regexp.new(READONLY_R)
|
4003
|
+
@@pattern_multiple_m = Regexp.new(MULTIPLE_M)
|
4004
|
+
@@pattern_multiple_m1 = Regexp.new(MULTIPLE_M1)
|
4005
|
+
@@pattern_multiple_r = Regexp.new(MULTIPLE_R)
|
3929
4006
|
|
3930
|
-
|
3931
|
-
|
4007
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
4008
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
4009
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
4010
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
4011
|
+
@@pattern_ap_1 = Regexp.new(AP_1)
|
4012
|
+
@@pattern_space_1 = Regexp.new(SPACE)
|
4013
|
+
@@pattern_br_1 = Regexp.new(BR_1)
|
4014
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
4015
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
4016
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
4017
|
+
@@pattern_ap_2 = Regexp.new(AP_2)
|
4018
|
+
@@pattern_space_2 = Regexp.new(NBSP_2)
|
4019
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
4020
|
+
@@pattern_br_2 = Regexp.new(BR_3)
|
4021
|
+
|
4022
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
4023
|
+
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
4024
|
+
|
4025
|
+
#@@pattern_match_tag = Regexp.new(MATCH_TAG)
|
4026
|
+
#@@pattern_match_tag2 = Regexp.new(MATCH_TAG_2)
|
4027
|
+
end
|
3932
4028
|
|
3933
4029
|
#
|
3934
4030
|
# イニシャライザ
|
3935
|
-
# @
|
4031
|
+
# @overload def initialize
|
4032
|
+
# @overload def initialize(ps)
|
4033
|
+
# @param [Meteor::Parser] ps パーサ
|
3936
4034
|
#
|
3937
4035
|
def initialize(*args)
|
3938
|
-
super(
|
4036
|
+
super()
|
4037
|
+
@doc_type = Parser::XHTML
|
3939
4038
|
case args.length
|
3940
4039
|
when ZERO
|
3941
4040
|
initialize_0
|
@@ -3955,7 +4054,6 @@ module Meteor
|
|
3955
4054
|
|
3956
4055
|
#
|
3957
4056
|
# イニシャライザ
|
3958
|
-
#
|
3959
4057
|
# @param [Meteor::Parser] ps パーサ
|
3960
4058
|
#
|
3961
4059
|
def initialize_1(ps)
|
@@ -3963,13 +4061,11 @@ module Meteor
|
|
3963
4061
|
@root.hook_document = String.new(ps.root_element.hook_document)
|
3964
4062
|
@root.content_type = String.new(ps.content_type)
|
3965
4063
|
@root.kaigyo_code = ps.root_element.kaigyo_code
|
3966
|
-
@doc_type = ps.doc_type
|
3967
4064
|
end
|
3968
4065
|
private :initialize_1
|
3969
4066
|
|
3970
4067
|
#
|
3971
4068
|
# ドキュメントをパーサにセットする
|
3972
|
-
#
|
3973
4069
|
# @param [String] document ドキュメント
|
3974
4070
|
#
|
3975
4071
|
def parse(document)
|
@@ -3979,7 +4075,6 @@ module Meteor
|
|
3979
4075
|
|
3980
4076
|
#
|
3981
4077
|
# ファイルを読み込み、パーサにセットする
|
3982
|
-
#
|
3983
4078
|
# @param file_path ファイルパス
|
3984
4079
|
# @param encoding エンコーディング
|
3985
4080
|
#
|
@@ -4002,7 +4097,6 @@ module Meteor
|
|
4002
4097
|
|
4003
4098
|
#
|
4004
4099
|
# コンテントタイプを取得する
|
4005
|
-
#
|
4006
4100
|
# @return [String] コンテントタイプ
|
4007
4101
|
#
|
4008
4102
|
def content_type()
|
@@ -4096,15 +4190,15 @@ module Meteor
|
|
4096
4190
|
|
4097
4191
|
def get_attribute_value_(elm,attr_name)
|
4098
4192
|
if is_match(SELECTED, attr_name) && is_match(OPTION,elm.name) then
|
4099
|
-
|
4193
|
+
get_attribute_value_r(elm,attr_name,@@pattern_selected_m1)
|
4100
4194
|
elsif is_match(MULTIPLE, attr_name) && is_match(SELECT,elm.name)
|
4101
|
-
|
4195
|
+
get_attribute_value_r(elm,attr_name,@@pattern_multiple_m1)
|
4102
4196
|
elsif is_match(DISABLED, attr_name) && is_match(DISABLE_ELEMENT, elm.name) then
|
4103
|
-
|
4197
|
+
get_attribute_value_r(elm,attr_name,@@pattern_disabled_m1)
|
4104
4198
|
elsif is_match(CHECKED, attr_name) && is_match(INPUT,elm.name) && is_match(RADIO, get_type(elm)) then
|
4105
|
-
|
4199
|
+
get_attribute_value_r(elm,attr_name,@@pattern_checked_m1)
|
4106
4200
|
elsif is_match(READONLY, attr_name) && (is_match(TEXTAREA,elm.name) || (is_match(INPUT,elm.name) && is_match(READONLY_TYPE, get_type(elm)))) then
|
4107
|
-
|
4201
|
+
get_attribute_value_r(elm,attr_name,@@pattern_readonly_m1)
|
4108
4202
|
else
|
4109
4203
|
super(elm,attr_name)
|
4110
4204
|
end
|
@@ -4113,16 +4207,16 @@ module Meteor
|
|
4113
4207
|
|
4114
4208
|
def get_type(elm)
|
4115
4209
|
if !elm.type_value
|
4116
|
-
elm.type_value =
|
4210
|
+
elm.type_value = get_attribute_value(elm, TYPE_L)
|
4117
4211
|
if !elm.type_value then
|
4118
|
-
elm.type_value =
|
4212
|
+
elm.type_value = get_attribute_value(elm, TYPE_U)
|
4119
4213
|
end
|
4120
4214
|
end
|
4121
4215
|
elm.type_value
|
4122
4216
|
end
|
4123
4217
|
private :get_type
|
4124
4218
|
|
4125
|
-
def
|
4219
|
+
def get_attribute_value_r(elm,attr_name,match_p)
|
4126
4220
|
|
4127
4221
|
@res = match_p.match(elm.attributes)
|
4128
4222
|
|
@@ -4156,7 +4250,7 @@ module Meteor
|
|
4156
4250
|
FALSE
|
4157
4251
|
end
|
4158
4252
|
end
|
4159
|
-
private :
|
4253
|
+
private :get_attribute_value_r
|
4160
4254
|
|
4161
4255
|
#
|
4162
4256
|
# 属性マップを取得する
|
@@ -4164,7 +4258,7 @@ module Meteor
|
|
4164
4258
|
# @param [Meteor::Element] elm 要素
|
4165
4259
|
# @return [Meteor::AttributeMap] 属性マップ
|
4166
4260
|
#
|
4167
|
-
def
|
4261
|
+
def get_attribute_map(elm)
|
4168
4262
|
attrs = Meteor::AttributeMap.new
|
4169
4263
|
|
4170
4264
|
elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
|
@@ -4178,7 +4272,7 @@ module Meteor
|
|
4178
4272
|
|
4179
4273
|
attrs
|
4180
4274
|
end
|
4181
|
-
private :
|
4275
|
+
private :get_attribute_map
|
4182
4276
|
|
4183
4277
|
def set_mono_info(elm)
|
4184
4278
|
|
@@ -4333,29 +4427,30 @@ module Meteor
|
|
4333
4427
|
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
4334
4428
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
4335
4429
|
else
|
4336
|
-
@@pattern_and_1 = Regexp.new(AND_1
|
4337
|
-
@@pattern_lt_1 = Regexp.new(LT_1
|
4338
|
-
@@pattern_gt_1 = Regexp.new(GT_1
|
4339
|
-
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION
|
4340
|
-
@@pattern_ap_1 = Regexp.new(AP_1
|
4341
|
-
@@pattern_lt_2 = Regexp.new(LT_2
|
4342
|
-
@@pattern_gt_2 = Regexp.new(GT_2
|
4343
|
-
@@pattern_dq_2 = Regexp.new(QO_2
|
4344
|
-
@@pattern_ap_2 = Regexp.new(AP_2
|
4345
|
-
@@pattern_and_2 = Regexp.new(AND_2
|
4346
|
-
|
4347
|
-
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE
|
4348
|
-
@@pattern_set_mono1 = Regexp.new(SET_MONO_1
|
4430
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
4431
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
4432
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
4433
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
4434
|
+
@@pattern_ap_1 = Regexp.new(AP_1)
|
4435
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
4436
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
4437
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
4438
|
+
@@pattern_ap_2 = Regexp.new(AP_2)
|
4439
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
4440
|
+
|
4441
|
+
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
4442
|
+
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
4349
4443
|
end
|
4350
4444
|
|
4351
4445
|
#
|
4352
4446
|
# イニシャライザ
|
4353
|
-
#
|
4354
|
-
# @
|
4447
|
+
# @overload def initialize
|
4448
|
+
# @overload def initialize(ps)
|
4449
|
+
# @param [Meteor::Parser] ps パーサ
|
4355
4450
|
#
|
4356
4451
|
def initialize(*args)
|
4357
|
-
super(
|
4358
|
-
|
4452
|
+
super()
|
4453
|
+
@doc_type = Parser::XML
|
4359
4454
|
case args.length
|
4360
4455
|
when ZERO
|
4361
4456
|
initialize_0
|
@@ -4375,19 +4470,16 @@ module Meteor
|
|
4375
4470
|
|
4376
4471
|
#
|
4377
4472
|
# イニシャライザ
|
4378
|
-
#
|
4379
4473
|
# @param [Meteor::Parser] ps パーサ
|
4380
4474
|
#
|
4381
4475
|
def initialize_1(ps)
|
4382
4476
|
@root.document = String.new(ps.document)
|
4383
4477
|
@root.hook_document = String.new(ps.root_element.hook_document)
|
4384
|
-
@doc_type = ps.doc_type
|
4385
4478
|
end
|
4386
4479
|
private :initialize_1
|
4387
4480
|
|
4388
4481
|
#
|
4389
4482
|
# ドキュメントをパーサにセットする
|
4390
|
-
#
|
4391
4483
|
# @param [String] document ドキュメント
|
4392
4484
|
#
|
4393
4485
|
def parse(document)
|
@@ -4396,7 +4488,6 @@ module Meteor
|
|
4396
4488
|
|
4397
4489
|
#
|
4398
4490
|
# ファイルを読み込み、パーサにセットする
|
4399
|
-
#
|
4400
4491
|
# @param file_path ファイルパス
|
4401
4492
|
# @param encoding エンコーディング
|
4402
4493
|
#
|
@@ -4405,7 +4496,6 @@ module Meteor
|
|
4405
4496
|
end
|
4406
4497
|
|
4407
4498
|
# コンテントタイプを取得する
|
4408
|
-
#
|
4409
4499
|
# @return [Streing]コンテントタイプ
|
4410
4500
|
#
|
4411
4501
|
def content_type()
|