asip-meteor 0.9.1.1 → 0.9.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/meteor.rb +793 -772
- metadata +2 -2
data/lib/meteor.rb
CHANGED
@@ -18,16 +18,20 @@
|
|
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.1.
|
21
|
+
# @version 0.9.1.2
|
22
22
|
#
|
23
|
-
|
23
|
+
|
24
|
+
|
25
|
+
RUBY_VERSION_1_9_0 = '1.9.0'
|
26
|
+
|
27
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0 then
|
24
28
|
require 'kconv'
|
25
29
|
end
|
26
30
|
|
27
31
|
|
28
32
|
module Meteor
|
29
33
|
|
30
|
-
VERSION = "0.9.1.
|
34
|
+
VERSION = "0.9.1.2"
|
31
35
|
|
32
36
|
#
|
33
37
|
# 要素クラス
|
@@ -70,6 +74,7 @@ module Meteor
|
|
70
74
|
#@parent = false
|
71
75
|
@arguments = AttributeMap.new
|
72
76
|
@origin = self.object_id
|
77
|
+
@usable = 0
|
73
78
|
end
|
74
79
|
|
75
80
|
#
|
@@ -92,7 +97,7 @@ module Meteor
|
|
92
97
|
@usable = 0
|
93
98
|
end
|
94
99
|
|
95
|
-
def self.
|
100
|
+
def self.new?(elm)
|
96
101
|
@obj = elm.parser.e_cache[elm.origin]
|
97
102
|
if @obj then
|
98
103
|
@obj.attributes = String.new(elm.attributes)
|
@@ -137,8 +142,8 @@ module Meteor
|
|
137
142
|
#
|
138
143
|
# @return [Meteor::AttributeMap] 属性マップ
|
139
144
|
#
|
140
|
-
def
|
141
|
-
@parser.
|
145
|
+
def attribute_map
|
146
|
+
@parser.attribute_map(self)
|
142
147
|
end
|
143
148
|
|
144
149
|
#
|
@@ -184,15 +189,15 @@ module Meteor
|
|
184
189
|
#
|
185
190
|
# @param args 引数配列
|
186
191
|
#
|
187
|
-
def
|
188
|
-
@parser.
|
192
|
+
def remove_attribute(*args)
|
193
|
+
@parser.remove_attribute(self,*args)
|
189
194
|
end
|
190
195
|
|
191
196
|
#
|
192
197
|
# 要素を削除する
|
193
198
|
#
|
194
199
|
def remove
|
195
|
-
@parser.
|
200
|
+
@parser.remove_element(self)
|
196
201
|
end
|
197
202
|
|
198
203
|
end
|
@@ -211,26 +216,26 @@ module Meteor
|
|
211
216
|
#改行コード
|
212
217
|
#@kaigyoCode = ''
|
213
218
|
#文字コード
|
214
|
-
#@
|
219
|
+
#@character_encoding=''
|
215
220
|
|
216
221
|
#フックドキュメント
|
217
|
-
@
|
222
|
+
@hook_document =''
|
218
223
|
#フック判定フラグ
|
219
224
|
#@hook = false
|
220
225
|
#単一要素フック判定フラグ
|
221
|
-
#@
|
226
|
+
#@mono_hook = false
|
222
227
|
#要素
|
223
228
|
#@element = nil
|
224
229
|
#変更可能要素
|
225
230
|
#@mutableElement = nil
|
226
231
|
end
|
227
232
|
|
228
|
-
attr_accessor :
|
229
|
-
attr_accessor :
|
230
|
-
attr_accessor :
|
231
|
-
attr_accessor :
|
233
|
+
attr_accessor :content_type
|
234
|
+
attr_accessor :kaigyo_code
|
235
|
+
attr_accessor :character_encoding
|
236
|
+
attr_accessor :hook_document
|
232
237
|
attr_accessor :hook;
|
233
|
-
attr_accessor :
|
238
|
+
attr_accessor :mono_hook
|
234
239
|
attr_accessor :element
|
235
240
|
attr_accessor :mutableElement
|
236
241
|
attr_accessor :document
|
@@ -257,7 +262,7 @@ module Meteor
|
|
257
262
|
#
|
258
263
|
def initialize_0
|
259
264
|
@map = Hash.new
|
260
|
-
if RUBY_VERSION <
|
265
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0
|
261
266
|
@names = Array.new
|
262
267
|
end
|
263
268
|
@recordable = false
|
@@ -266,13 +271,13 @@ module Meteor
|
|
266
271
|
#
|
267
272
|
# イニシャライザ
|
268
273
|
#
|
269
|
-
def initialize_1(
|
274
|
+
def initialize_1(attr_map)
|
270
275
|
#@map = Marshal.load(Marshal.dump(attrMap.map))
|
271
|
-
@map =
|
272
|
-
if RUBY_VERSION <
|
273
|
-
@names = Array.new(
|
276
|
+
@map = attr_map.map.dup
|
277
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0
|
278
|
+
@names = Array.new(attr_map.names)
|
274
279
|
end
|
275
|
-
@recordable =
|
280
|
+
@recordable = attr_map.recordable
|
276
281
|
end
|
277
282
|
|
278
283
|
#
|
@@ -292,7 +297,7 @@ module Meteor
|
|
292
297
|
attr.removed = false
|
293
298
|
end
|
294
299
|
@map[name] = attr
|
295
|
-
if RUBY_VERSION <
|
300
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0
|
296
301
|
@names << name
|
297
302
|
end
|
298
303
|
else
|
@@ -312,7 +317,7 @@ module Meteor
|
|
312
317
|
# @return [Array] 属性名配列
|
313
318
|
#
|
314
319
|
def names
|
315
|
-
if RUBY_VERSION <
|
320
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0
|
316
321
|
@names
|
317
322
|
else
|
318
323
|
@map.keys
|
@@ -457,15 +462,15 @@ module Meteor
|
|
457
462
|
when Parser::HTML then
|
458
463
|
html = Meteor::Core::Html::ParserImpl.new()
|
459
464
|
html.read(path, encoding)
|
460
|
-
psf.
|
465
|
+
psf.parser = html
|
461
466
|
when Parser::XHTML then
|
462
467
|
xhtml = Meteor::Core::Xhtml::ParserImpl.new()
|
463
468
|
xhtml.read(path, encoding)
|
464
|
-
psf.
|
469
|
+
psf.parser = xhtml
|
465
470
|
when Parser::XML then
|
466
471
|
xml = Meteor::Core::Xml::ParserImpl.new()
|
467
472
|
xml.read(path, encoding)
|
468
|
-
psf.
|
473
|
+
psf.parser = xml
|
469
474
|
end
|
470
475
|
|
471
476
|
psf
|
@@ -486,15 +491,15 @@ module Meteor
|
|
486
491
|
when Parser::HTML then
|
487
492
|
html = Meteor::Core::Html::ParserImpl.new()
|
488
493
|
html.parse(document)
|
489
|
-
psf.
|
494
|
+
psf.parser = html
|
490
495
|
when Parser::XHTML then
|
491
496
|
xhtml = Meteor::Core::Xhtml::ParserImpl.new()
|
492
497
|
xhtml.parse(document)
|
493
|
-
psf.
|
498
|
+
psf.parser = xhtml
|
494
499
|
when Parser::XML then
|
495
500
|
xml = Meteor::Core::Xml::ParserImpl.new()
|
496
501
|
xml.parse(document)
|
497
|
-
psf.
|
502
|
+
psf.parser = xml
|
498
503
|
end
|
499
504
|
|
500
505
|
psf
|
@@ -506,7 +511,7 @@ module Meteor
|
|
506
511
|
#
|
507
512
|
# @param [Meteor::Parser] パーサ
|
508
513
|
#
|
509
|
-
def
|
514
|
+
def parser=(pif)
|
510
515
|
@pif = pif
|
511
516
|
end
|
512
517
|
|
@@ -515,7 +520,7 @@ module Meteor
|
|
515
520
|
#
|
516
521
|
# @return [Meteor::Parser] パーサ
|
517
522
|
#
|
518
|
-
def
|
523
|
+
def parser
|
519
524
|
|
520
525
|
if @pif.instance_of?(Meteor::Core::Html::ParserImpl) then
|
521
526
|
Meteor::Core::Html::ParserImpl.new(@pif)
|
@@ -541,7 +546,7 @@ module Meteor
|
|
541
546
|
def initialize
|
542
547
|
end
|
543
548
|
|
544
|
-
def
|
549
|
+
def do_action(elm,pif)
|
545
550
|
#内容あり要素の場合
|
546
551
|
if elm.empty then
|
547
552
|
pif2 = pif.child(elm)
|
@@ -565,18 +570,18 @@ module Meteor
|
|
565
570
|
def initialize
|
566
571
|
end
|
567
572
|
|
568
|
-
def
|
573
|
+
def do_action(elm,pif,list)
|
569
574
|
#内容あり要素の場合
|
570
575
|
if elm.empty then
|
571
576
|
pif2 = pif.child(elm)
|
572
577
|
|
573
|
-
list.each
|
574
|
-
if pif2.
|
575
|
-
pif2.
|
576
|
-
|
578
|
+
list.each do |item|
|
579
|
+
if pif2.root_element.hook then
|
580
|
+
pif2.root_element.document = elm.mixed_content
|
581
|
+
#elsif pif2.rootElement.mono_hook then
|
577
582
|
end
|
578
|
-
execute(pif2,item)
|
579
|
-
|
583
|
+
execute(pif2, item)
|
584
|
+
end
|
580
585
|
pif2.flush
|
581
586
|
end
|
582
587
|
end
|
@@ -801,7 +806,7 @@ module Meteor
|
|
801
806
|
#@pattern = nil
|
802
807
|
#ルート要素
|
803
808
|
@root = RootElement.new
|
804
|
-
if RUBY_VERSION >=
|
809
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
805
810
|
@e_cache = Hash.new()
|
806
811
|
else
|
807
812
|
@e_cache = Meteor::Core::Util::OrderHash.new
|
@@ -880,8 +885,8 @@ module Meteor
|
|
880
885
|
#
|
881
886
|
# @pamam [TrueClass][FalseClass] hook 単一要素フックフラグ
|
882
887
|
#
|
883
|
-
#def
|
884
|
-
# @root.
|
888
|
+
#def mono_hook=(hook)
|
889
|
+
# @root.mono_hook = hook
|
885
890
|
#end
|
886
891
|
|
887
892
|
#
|
@@ -889,8 +894,8 @@ module Meteor
|
|
889
894
|
#
|
890
895
|
# @return [TrueClass][FalseClass] 単一要素フックフラグ
|
891
896
|
#
|
892
|
-
#def
|
893
|
-
# @root.
|
897
|
+
#def mono_hook
|
898
|
+
# @root.mono_hook
|
894
899
|
#end
|
895
900
|
|
896
901
|
#
|
@@ -916,8 +921,8 @@ module Meteor
|
|
916
921
|
#
|
917
922
|
# @param [String] enc 文字エンコーディング
|
918
923
|
#
|
919
|
-
def
|
920
|
-
@root.
|
924
|
+
def character_encoding=(enc)
|
925
|
+
@root.character_encoding = enc
|
921
926
|
end
|
922
927
|
|
923
928
|
#
|
@@ -925,8 +930,8 @@ module Meteor
|
|
925
930
|
#
|
926
931
|
# @param [String] 文字エンコーディング
|
927
932
|
#
|
928
|
-
def
|
929
|
-
@root.
|
933
|
+
def character_encoding
|
934
|
+
@root.character_encoding
|
930
935
|
end
|
931
936
|
|
932
937
|
#
|
@@ -934,7 +939,7 @@ module Meteor
|
|
934
939
|
#
|
935
940
|
# @return [Meteor::RootElement] ルート要素
|
936
941
|
#
|
937
|
-
def
|
942
|
+
def root_element
|
938
943
|
@root
|
939
944
|
end
|
940
945
|
|
@@ -944,18 +949,18 @@ module Meteor
|
|
944
949
|
# @param [String] filePath 入力ファイルの絶対パス
|
945
950
|
# @param [String] encoding 入力ファイルの文字コード
|
946
951
|
#
|
947
|
-
def read(
|
952
|
+
def read(file_path, encoding)
|
948
953
|
|
949
954
|
#try {
|
950
|
-
@
|
955
|
+
@character_encoding = encoding
|
951
956
|
#ファイルのオープン
|
952
|
-
if RUBY_VERSION >=
|
953
|
-
io = File.open(
|
957
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
958
|
+
io = File.open(file_path,'r:' << encoding)
|
954
959
|
#読込及び格納
|
955
960
|
@root.document = io.read
|
956
961
|
else
|
957
962
|
#読込及び格納
|
958
|
-
io = open(
|
963
|
+
io = open(file_path,'r')
|
959
964
|
@root.document = io.read
|
960
965
|
@root.document = @root.document.kconv(get_encoding(), Kconv.guess(@root.document))
|
961
966
|
end
|
@@ -978,21 +983,21 @@ module Meteor
|
|
978
983
|
end
|
979
984
|
|
980
985
|
def get_encoding()
|
981
|
-
case @
|
986
|
+
case @character_encoding
|
982
987
|
when 'UTF-8'
|
983
|
-
|
988
|
+
kconv::UTF8
|
984
989
|
when 'ISO-2022-JP'
|
985
|
-
|
990
|
+
kconv::JIS
|
986
991
|
when 'Shift_JIS'
|
987
|
-
|
992
|
+
kconv::SJIS
|
988
993
|
when 'EUC-JP'
|
989
|
-
|
994
|
+
kconv::EUC
|
990
995
|
when 'ASCII'
|
991
|
-
|
996
|
+
kconv::ASCII
|
992
997
|
#when "UTF-16"
|
993
998
|
# return KConv::UTF16
|
994
999
|
else
|
995
|
-
|
1000
|
+
kconv::UTF8
|
996
1001
|
end
|
997
1002
|
end
|
998
1003
|
private :get_encoding
|
@@ -1023,24 +1028,24 @@ module Meteor
|
|
1023
1028
|
#
|
1024
1029
|
# 要素名で検索し、要素を取得する
|
1025
1030
|
#
|
1026
|
-
# @param [String]
|
1031
|
+
# @param [String] elm_name 要素名
|
1027
1032
|
# @return [Meteor::Element] 要素
|
1028
1033
|
#
|
1029
|
-
def element_1(
|
1034
|
+
def element_1(elm_name)
|
1030
1035
|
|
1031
|
-
@
|
1036
|
+
@_elm_name = escape_regex(elm_name)
|
1032
1037
|
|
1033
1038
|
#空要素検索用パターン
|
1034
|
-
@pattern_cc_1 = '' << TAG_OPEN << @
|
1039
|
+
@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_1_3
|
1035
1040
|
|
1036
1041
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
1037
1042
|
#空要素検索
|
1038
1043
|
@res1 = @pattern.match(@root.document)
|
1039
1044
|
|
1040
1045
|
#内容あり要素検索用パターン
|
1041
|
-
#@pattern_cc_2 = '' << TAG_OPEN << @
|
1042
|
-
#@pattern_cc_2 << TAG_SEARCH_1_2 << @
|
1043
|
-
@pattern_cc_2 = "<#{@
|
1046
|
+
#@pattern_cc_2 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_1_1 << elm_name
|
1047
|
+
#@pattern_cc_2 << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
1048
|
+
@pattern_cc_2 = "<#{@_elm_name}(\\s?[^<>]*)>(((?!(#{@_elm_name}[^<>]*>)).)*)<\\/#{@_elm_name}>"
|
1044
1049
|
|
1045
1050
|
|
1046
1051
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
@@ -1051,32 +1056,32 @@ module Meteor
|
|
1051
1056
|
if @res1.end(0) < @res2.end(0) then
|
1052
1057
|
@res = @res1
|
1053
1058
|
@pattern_cc = @pattern_cc_1
|
1054
|
-
@elm_ =
|
1059
|
+
@elm_ = element_without_1(elm_name)
|
1055
1060
|
elsif @res1.end(0) > @res2.end(0)
|
1056
1061
|
@res = @res2
|
1057
1062
|
@pattern_cc = @pattern_cc_2
|
1058
|
-
@elm_ =
|
1063
|
+
@elm_ = element_with_1(elm_name)
|
1059
1064
|
end
|
1060
1065
|
elsif @res1 && !@res2 then
|
1061
1066
|
@res = @res1
|
1062
1067
|
@pattern_cc = @pattern_cc_1
|
1063
|
-
@elm_ =
|
1068
|
+
@elm_ = element_without_1(elm_name)
|
1064
1069
|
elsif !@res1 && @res2 then
|
1065
1070
|
@res = @res2
|
1066
1071
|
@pattern_cc = @pattern_cc_2
|
1067
|
-
@elm_ =
|
1072
|
+
@elm_ = element_with_1(elm_name)
|
1068
1073
|
elsif !@res1 && !@res2 then
|
1069
1074
|
@elm_ = nil
|
1070
|
-
#raise NoSuchElementException.new(
|
1075
|
+
#raise NoSuchElementException.new(elm_name);
|
1071
1076
|
end
|
1072
1077
|
|
1073
1078
|
@elm_
|
1074
1079
|
end
|
1075
1080
|
private :element_1
|
1076
1081
|
|
1077
|
-
def
|
1082
|
+
def element_with_1(elm_name)
|
1078
1083
|
|
1079
|
-
@elm_ = Element.new(
|
1084
|
+
@elm_ = Element.new(elm_name)
|
1080
1085
|
#属性
|
1081
1086
|
@elm_.attributes = @res[1]
|
1082
1087
|
#内容
|
@@ -1084,9 +1089,9 @@ module Meteor
|
|
1084
1089
|
#全体
|
1085
1090
|
@elm_.document = @res[0]
|
1086
1091
|
|
1087
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
1088
|
-
#@pattern_cc << TAG_SEARCH_NC_1_2 << @
|
1089
|
-
@pattern_cc = "<#{@
|
1092
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_NC_1_1 << elm_name
|
1093
|
+
#@pattern_cc << TAG_SEARCH_NC_1_2 << @_elm_name << TAG_CLOSE
|
1094
|
+
@pattern_cc = "<#{@_elm_name}\\s?[^<>]*>((?!(#{@_elm_name}[^<>]*>)).)*<\\/#{@_elm_name}>"
|
1090
1095
|
|
1091
1096
|
#内容あり要素検索用パターン
|
1092
1097
|
@elm_.pattern = @pattern_cc
|
@@ -1097,17 +1102,17 @@ module Meteor
|
|
1097
1102
|
|
1098
1103
|
@elm_
|
1099
1104
|
end
|
1100
|
-
private :
|
1105
|
+
private :element_with_1
|
1101
1106
|
|
1102
|
-
def
|
1107
|
+
def element_without_1(elm_name)
|
1103
1108
|
#要素
|
1104
|
-
@elm_ = Element.new(
|
1109
|
+
@elm_ = Element.new(elm_name)
|
1105
1110
|
#属性
|
1106
1111
|
@elm_.attributes = @res[1]
|
1107
1112
|
#全体
|
1108
1113
|
@elm_.document = @res[0]
|
1109
1114
|
#空要素検索用パターン
|
1110
|
-
@pattern_cc = '' << TAG_OPEN << @
|
1115
|
+
@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_NC_1_3
|
1111
1116
|
@elm_.pattern = @pattern_cc
|
1112
1117
|
|
1113
1118
|
@elm_.empty = false
|
@@ -1116,43 +1121,43 @@ module Meteor
|
|
1116
1121
|
|
1117
1122
|
@elm_
|
1118
1123
|
end
|
1119
|
-
private :
|
1124
|
+
private :element_without_1
|
1120
1125
|
|
1121
1126
|
#
|
1122
1127
|
# 要素名と属性で検索し、要素を取得する
|
1123
1128
|
#
|
1124
|
-
# @param [String]
|
1129
|
+
# @param [String] elm_name 要素名
|
1125
1130
|
# @param [String] attrName 属性名
|
1126
|
-
# @param [String]
|
1131
|
+
# @param [String] attr_value 属性値
|
1127
1132
|
# @return [Meteor::Element] 要素
|
1128
1133
|
#
|
1129
|
-
def element_3(
|
1134
|
+
def element_3(elm_name,attr_name,attr_value)
|
1130
1135
|
|
1131
|
-
@
|
1132
|
-
@
|
1133
|
-
@
|
1136
|
+
@_elm_name = escape_regex(elm_name)
|
1137
|
+
@_attr_name = escape_regex(attr_name)
|
1138
|
+
@_attr_value = escape_regex(attr_value)
|
1134
1139
|
|
1135
1140
|
#空要素検索用パターン
|
1136
|
-
#@pattern_cc_1 = '' << TAG_OPEN << @
|
1137
|
-
#@pattern_cc_1 << @
|
1138
|
-
@pattern_cc_1 = "<#{@
|
1141
|
+
#@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
1142
|
+
#@pattern_cc_1 << @_attr_value << TAG_SEARCH_2_3_2
|
1143
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)\\/>"
|
1139
1144
|
|
1140
1145
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
1141
1146
|
#空要素検索
|
1142
1147
|
@res1 = @pattern.match(@root.document)
|
1143
1148
|
|
1144
1149
|
#内容あり要素検索パターン
|
1145
|
-
#@pattern_cc_2 = '' << TAG_OPEN << @
|
1146
|
-
#@pattern_cc_2 << @
|
1147
|
-
#@pattern_cc_2 << TAG_SEARCH_1_2 << @
|
1148
|
-
@pattern_cc_2 = "<#{@
|
1150
|
+
#@pattern_cc_2 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
1151
|
+
#@pattern_cc_2 << @_attr_value << TAG_SEARCH_2_2 << @_elm_name
|
1152
|
+
#@pattern_cc_2 << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
1153
|
+
@pattern_cc_2 = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(#{@_elm_name}[^<>]*>)).)*)<\\/#{@_elm_name}>"
|
1149
1154
|
|
1150
1155
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
1151
1156
|
#内容あり要素検索
|
1152
1157
|
@res2 = @pattern.match(@root.document)
|
1153
1158
|
|
1154
1159
|
if !@res2 then
|
1155
|
-
@res2 =
|
1160
|
+
@res2 = element_with_3_2(elm_name)
|
1156
1161
|
@pattern_cc_2 = @pattern_cc
|
1157
1162
|
end
|
1158
1163
|
|
@@ -1160,27 +1165,27 @@ module Meteor
|
|
1160
1165
|
if @res1.begin(0) < @res2.begin(0) then
|
1161
1166
|
@res = @res1
|
1162
1167
|
@pattern_cc = @pattern_cc_1
|
1163
|
-
|
1168
|
+
element_without_3(elm_name)
|
1164
1169
|
elsif @res1.begin(0) > @res2.begin(0)
|
1165
1170
|
@res = @res2
|
1166
1171
|
@pattern_cc = @pattern_cc_2
|
1167
|
-
|
1172
|
+
element_with_3_1(elm_name)
|
1168
1173
|
end
|
1169
1174
|
elsif @res1 && !@res2 then
|
1170
1175
|
@res = @res1
|
1171
1176
|
@pattern_cc = @pattern_cc_1
|
1172
|
-
|
1177
|
+
element_without_3(elm_name)
|
1173
1178
|
elsif !@res1 && @res2 then
|
1174
1179
|
@res = @res2
|
1175
1180
|
@pattern_cc = @pattern_cc_2
|
1176
|
-
|
1181
|
+
element_with_3_1(elm_name)
|
1177
1182
|
elsif !@res1 && !@res2 then
|
1178
1183
|
@elm_ = nil
|
1179
|
-
#raise NoSuchElementException.new(
|
1184
|
+
#raise NoSuchElementException.new(elm_name,attr_name,attr_value);
|
1180
1185
|
end
|
1181
1186
|
|
1182
1187
|
if @elm_ then
|
1183
|
-
@elm_.arguments.store(
|
1188
|
+
@elm_.arguments.store(attr_name, attr_value)
|
1184
1189
|
@elm_.arguments.recordable = true
|
1185
1190
|
end
|
1186
1191
|
|
@@ -1188,11 +1193,11 @@ module Meteor
|
|
1188
1193
|
end
|
1189
1194
|
private :element_3
|
1190
1195
|
|
1191
|
-
def
|
1196
|
+
def element_with_3_1(elm_name)
|
1192
1197
|
|
1193
1198
|
if @res.captures.length == 4 then
|
1194
1199
|
#要素
|
1195
|
-
@elm_ = Element.new(
|
1200
|
+
@elm_ = Element.new(elm_name)
|
1196
1201
|
#属性
|
1197
1202
|
@elm_.attributes = @res[1]
|
1198
1203
|
#内容
|
@@ -1200,10 +1205,10 @@ module Meteor
|
|
1200
1205
|
#全体
|
1201
1206
|
@elm_.document = @res[0]
|
1202
1207
|
#内容あり要素検索用パターン
|
1203
|
-
#@pattern_cc = ''<< TAG_OPEN << @
|
1204
|
-
#@pattern_cc << @
|
1205
|
-
#@pattern_cc << TAG_SEARCH_NC_1_2 << @
|
1206
|
-
@pattern_cc = "<#{@
|
1208
|
+
#@pattern_cc = ''<< TAG_OPEN << @_elm_name << TAG_SEARCH_NC_2_1 << @_attr_name << ATTR_EQ
|
1209
|
+
#@pattern_cc << @_attr_value << TAG_SEARCH_NC_2_2 << @_elm_name
|
1210
|
+
#@pattern_cc << TAG_SEARCH_NC_1_2 << @_elm_name << TAG_CLOSE
|
1211
|
+
@pattern_cc = "<#{@_elm_name}\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*>((?!(#{@_elm_name}[^<>]*>)).)*<\\/#{@_elm_name}>"
|
1207
1212
|
|
1208
1213
|
@elm_.pattern = @pattern_cc
|
1209
1214
|
|
@@ -1213,7 +1218,7 @@ module Meteor
|
|
1213
1218
|
|
1214
1219
|
elsif @res.captures.length == 6 then
|
1215
1220
|
#内容
|
1216
|
-
@elm_ = Element.new(
|
1221
|
+
@elm_ = Element.new(elm_name)
|
1217
1222
|
#属性
|
1218
1223
|
@elm_.attributes = @res[1].chop
|
1219
1224
|
#内容
|
@@ -1228,27 +1233,27 @@ module Meteor
|
|
1228
1233
|
@elm_.parser = self
|
1229
1234
|
end
|
1230
1235
|
end
|
1231
|
-
private :
|
1236
|
+
private :element_with_3_1
|
1232
1237
|
|
1233
|
-
def
|
1238
|
+
def element_with_3_2(elm_name)
|
1234
1239
|
|
1235
|
-
#@pattern_cc_1 = '' << TAG_OPEN << @
|
1236
|
-
#@pattern_cc_1 << @
|
1237
|
-
@pattern_cc_1 = "<#{@
|
1240
|
+
#@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
1241
|
+
#@pattern_cc_1 << @_attr_value << TAG_SEARCH_2_4_2
|
1242
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}(?:[^<>\\/]*>|(?:(?!([^<>]*\\/>))[^<>]*>)))"
|
1238
1243
|
|
1239
|
-
@pattern_cc_1b = '' << TAG_OPEN << @
|
1244
|
+
@pattern_cc_1b = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_1_4
|
1240
1245
|
|
1241
|
-
#@pattern_cc_1_1 = '' << TAG_OPEN << @
|
1242
|
-
#@pattern_cc_1_1 << @
|
1243
|
-
@pattern_cc_1_1 = "<#{@
|
1246
|
+
#@pattern_cc_1_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
1247
|
+
#@pattern_cc_1_1 << @_attr_value << TAG_SEARCH_4_7
|
1248
|
+
@pattern_cc_1_1 = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"(?:[^<>\\/]*>|(?!([^<>]*\\/>))[^<>]*>))("
|
1244
1249
|
|
1245
|
-
@pattern_cc_1_2 = '' << TAG_SEARCH_4_2 << @
|
1250
|
+
@pattern_cc_1_2 = '' << TAG_SEARCH_4_2 << @_elm_name << TAG_SEARCH_4_3
|
1246
1251
|
|
1247
|
-
@pattern_cc_2 = '' << TAG_SEARCH_4_4 << @
|
1252
|
+
@pattern_cc_2 = '' << TAG_SEARCH_4_4 << @_elm_name << TAG_CLOSE
|
1248
1253
|
|
1249
|
-
@pattern_cc_2_1 = '' << TAG_SEARCH_4_5 << @
|
1254
|
+
@pattern_cc_2_1 = '' << TAG_SEARCH_4_5 << @_elm_name << TAG_CLOSE
|
1250
1255
|
|
1251
|
-
@pattern_cc_2_2 = '' << TAG_SEARCH_4_6 << @
|
1256
|
+
@pattern_cc_2_2 = '' << TAG_SEARCH_4_6 << @_elm_name << TAG_CLOSE
|
1252
1257
|
|
1253
1258
|
#内容あり要素検索
|
1254
1259
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
@@ -1265,7 +1270,7 @@ module Meteor
|
|
1265
1270
|
@pattern_cc = @sbuf
|
1266
1271
|
|
1267
1272
|
if @sbuf.length == 0 || @cnt != 0 then
|
1268
|
-
# raise NoSuchElementException.new(
|
1273
|
+
# raise NoSuchElementException.new(elm_name,attr_name,attr_value);
|
1269
1274
|
return nil;
|
1270
1275
|
end
|
1271
1276
|
|
@@ -1274,52 +1279,52 @@ module Meteor
|
|
1274
1279
|
|
1275
1280
|
@res
|
1276
1281
|
end
|
1277
|
-
private :
|
1282
|
+
private :element_with_3_2
|
1278
1283
|
|
1279
|
-
def
|
1280
|
-
|
1284
|
+
def element_without_3(elm_name)
|
1285
|
+
element_without_3_1(elm_name,TAG_SEARCH_NC_2_3_2)
|
1281
1286
|
end
|
1282
|
-
private :
|
1287
|
+
private :element_without_3
|
1283
1288
|
|
1284
|
-
def
|
1289
|
+
def element_without_3_1(elm_name,closer)
|
1285
1290
|
|
1286
1291
|
#要素
|
1287
|
-
@elm_ = Element.new(
|
1292
|
+
@elm_ = Element.new(elm_name)
|
1288
1293
|
#属性
|
1289
1294
|
@elm_.attributes = @res[1];
|
1290
1295
|
#全体
|
1291
1296
|
@elm_.document = @res[0]
|
1292
1297
|
#空要素検索用パターン
|
1293
|
-
@pattern_cc = '' << TAG_OPEN << @
|
1294
|
-
@pattern_cc << @
|
1298
|
+
@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_NC_2_1 << @_attr_name << ATTR_EQ
|
1299
|
+
@pattern_cc << @_attr_value << closer
|
1295
1300
|
@elm_.pattern = @pattern_cc
|
1296
1301
|
|
1297
1302
|
@elm_.parser = self
|
1298
1303
|
end
|
1299
|
-
private :
|
1304
|
+
private :element_without_3_1
|
1300
1305
|
|
1301
1306
|
#
|
1302
1307
|
# 属性(属性名="属性値")で検索し、要素を取得する
|
1303
1308
|
#
|
1304
|
-
# @param [String]
|
1305
|
-
# @param [String]
|
1309
|
+
# @param [String] attr_name 属性名
|
1310
|
+
# @param [String] attr_value 属性値
|
1306
1311
|
# @return [Meteor::Element] 要素
|
1307
1312
|
#
|
1308
|
-
def element_2(
|
1313
|
+
def element_2(attr_name,attr_value)
|
1309
1314
|
|
1310
|
-
@
|
1311
|
-
@
|
1315
|
+
@_attr_name = escape_regex(attr_name)
|
1316
|
+
@_attr_value = escape_regex(attr_value)
|
1312
1317
|
|
1313
|
-
##@pattern_cc = '' << TAG_SEARCH_3_1 << @
|
1314
|
-
#@pattern_cc = '' << TAG_SEARCH_3_1 << @
|
1315
|
-
@pattern_cc = "<([^<>\"]*)\\s[^<>]*#{@
|
1318
|
+
##@pattern_cc = '' << TAG_SEARCH_3_1 << @_attr_name << ATTR_EQ << @_attr_value << TAG_SEARCH_2_4
|
1319
|
+
#@pattern_cc = '' << TAG_SEARCH_3_1 << @_attr_name << ATTR_EQ << @_attr_value << TAG_SEARCH_2_4_2_3
|
1320
|
+
@pattern_cc = "<([^<>\"]*)\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\""
|
1316
1321
|
|
1317
1322
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
1318
1323
|
|
1319
1324
|
@res = @pattern.match(@root.document)
|
1320
1325
|
|
1321
1326
|
if @res then
|
1322
|
-
@elm_ = element_3(@res[1],
|
1327
|
+
@elm_ = element_3(@res[1], attr_name, attr_value)
|
1323
1328
|
else
|
1324
1329
|
@elm_ = nil
|
1325
1330
|
end
|
@@ -1331,48 +1336,48 @@ module Meteor
|
|
1331
1336
|
#
|
1332
1337
|
# 要素名と属性1・属性2で検索し、要素を取得する
|
1333
1338
|
#
|
1334
|
-
# @param [String]
|
1335
|
-
# @param [String]
|
1336
|
-
# @param [String]
|
1337
|
-
# @param [String]
|
1338
|
-
# @param [String]
|
1339
|
+
# @param [String] elm_name 要素の名前
|
1340
|
+
# @param [String] attr_name1 属性名1
|
1341
|
+
# @param [String] attr_value1 属性値2
|
1342
|
+
# @param [String] attr_name2 属性名2
|
1343
|
+
# @param [String] attr_value2 属性値2
|
1339
1344
|
# @return [Meteor::Element] 要素
|
1340
1345
|
#
|
1341
|
-
def element_5(
|
1346
|
+
def element_5(elm_name,attr_name1,attr_value1,attr_name2,attr_value2)
|
1342
1347
|
|
1343
|
-
@
|
1344
|
-
@
|
1345
|
-
@
|
1346
|
-
@
|
1347
|
-
@
|
1348
|
+
@_elm_name = escape_regex(elm_name)
|
1349
|
+
@_attr_name1 = escape_regex(attr_name1)
|
1350
|
+
@_attr_name2 = escape_regex(attr_name2)
|
1351
|
+
@_attr_value1 = escape_regex(attr_value1)
|
1352
|
+
@_attr_value2 = escape_regex(attr_value2)
|
1348
1353
|
|
1349
1354
|
#空要素検索用パターン
|
1350
|
-
#@pattern_cc_1 = '' << TAG_OPEN << @
|
1351
|
-
#@pattern_cc_1 << @
|
1352
|
-
#@pattern_cc_1 << @
|
1353
|
-
#@pattern_cc_1 << @
|
1354
|
-
#@pattern_cc_1 << @
|
1355
|
-
@pattern_cc_1 = "<#{@
|
1355
|
+
#@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
1356
|
+
#@pattern_cc_1 << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
1357
|
+
#@pattern_cc_1 << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
1358
|
+
#@pattern_cc_1 << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
1359
|
+
#@pattern_cc_1 << @_attr_value1 << TAG_SEARCH_2_3_2_2
|
1360
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)\\/>"
|
1356
1361
|
|
1357
1362
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
1358
1363
|
#空要素検索
|
1359
1364
|
@res1 = @pattern.match(@root.document)
|
1360
1365
|
|
1361
1366
|
#内容あり要素検索パターン
|
1362
|
-
#@pattern_cc_2 = '' << TAG_OPEN << @
|
1363
|
-
#@pattern_cc_2 << @
|
1364
|
-
#@pattern_cc_2 << @
|
1365
|
-
#@pattern_cc_2 << @
|
1366
|
-
#@pattern_cc_2 << @
|
1367
|
-
#@pattern_cc_2 << TAG_SEARCH_1_2 << @
|
1368
|
-
@pattern_cc_1 = "<#{@
|
1367
|
+
#@pattern_cc_2 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
1368
|
+
#@pattern_cc_2 << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
1369
|
+
#@pattern_cc_2 << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
1370
|
+
#@pattern_cc_2 << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
1371
|
+
#@pattern_cc_2 << @_attr_value1 << TAG_SEARCH_2_2_2 << @_elm_name
|
1372
|
+
#@pattern_cc_2 << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
1373
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_elm_name}[^<>]*>)).)*)<\\/#{@_elm_name}>"
|
1369
1374
|
|
1370
1375
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
|
1371
1376
|
#内容あり要素検索
|
1372
1377
|
@res2 = @pattern.match(@root.document)
|
1373
1378
|
|
1374
1379
|
if !@res2 then
|
1375
|
-
@res2 =
|
1380
|
+
@res2 = element_with_5_2(elm_name)
|
1376
1381
|
@pattern_cc_2 = @pattern_cc
|
1377
1382
|
end
|
1378
1383
|
|
@@ -1380,28 +1385,28 @@ module Meteor
|
|
1380
1385
|
if @res1.begin(0) < @res2.begin(0) then
|
1381
1386
|
@res = @res1
|
1382
1387
|
@pattern_cc = @pattern_cc_1
|
1383
|
-
|
1388
|
+
element_without_5(elm_name)
|
1384
1389
|
elsif @res1.begin(0) > @res2.begin(0)
|
1385
1390
|
@res = @res2
|
1386
1391
|
@pattern_cc = @pattern_cc_2
|
1387
|
-
|
1392
|
+
element_with_5_1(elm_name)
|
1388
1393
|
end
|
1389
1394
|
elsif @res1 && !@res2 then
|
1390
1395
|
@res = @res1
|
1391
1396
|
@pattern_cc = @pattern_cc_1
|
1392
|
-
|
1397
|
+
element_without_5(elm_name)
|
1393
1398
|
elsif !@res1 && @res2 then
|
1394
1399
|
@res = @res2
|
1395
1400
|
@pattern_cc = @pattern_cc_2
|
1396
|
-
|
1401
|
+
element_with_5_1(elm_name)
|
1397
1402
|
elsif !@res1 && !@res2 then
|
1398
1403
|
@elm_ = nil
|
1399
|
-
#raise NoSuchElementException.new(
|
1404
|
+
#raise NoSuchElementException.new(elm_name,attr_name1,attr_value1,attr_name2,attr_value2);
|
1400
1405
|
end
|
1401
1406
|
|
1402
1407
|
if @elm_ then
|
1403
|
-
@elm_.arguments.store(
|
1404
|
-
@elm_.arguments.store(
|
1408
|
+
@elm_.arguments.store(attr_name1, attr_value1)
|
1409
|
+
@elm_.arguments.store(attr_name2, attr_value2)
|
1405
1410
|
@elm_.arguments.recordable = true
|
1406
1411
|
end
|
1407
1412
|
|
@@ -1409,11 +1414,11 @@ module Meteor
|
|
1409
1414
|
end
|
1410
1415
|
private :element_5
|
1411
1416
|
|
1412
|
-
def
|
1417
|
+
def element_with_5_1(elm_name)
|
1413
1418
|
|
1414
1419
|
if @res.captures.length == 4 then
|
1415
1420
|
#要素
|
1416
|
-
@elm_ = Element.new(
|
1421
|
+
@elm_ = Element.new(elm_name)
|
1417
1422
|
#属性
|
1418
1423
|
@elm_.attributes = @res[1]
|
1419
1424
|
#内容
|
@@ -1421,13 +1426,13 @@ module Meteor
|
|
1421
1426
|
#全体
|
1422
1427
|
@elm_.document = @res[0]
|
1423
1428
|
#内容あり要素検索用パターン
|
1424
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
1425
|
-
#@pattern_cc << @
|
1426
|
-
#@pattern_cc << @
|
1427
|
-
#@pattern_cc << @
|
1428
|
-
#@pattern_cc << @
|
1429
|
-
#@pattern_cc << TAG_SEARCH_NC_1_2 << @
|
1430
|
-
@pattern_cc = "<#{@
|
1429
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_NC_2_1_2 << @_attr_name1 << ATTR_EQ
|
1430
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_NC_2_6 << @_attr_name2 << ATTR_EQ
|
1431
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_7 << @_attr_name2 << ATTR_EQ
|
1432
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_6 << @_attr_name1 << ATTR_EQ
|
1433
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_NC_2_2_2 << @_elm_name
|
1434
|
+
#@pattern_cc << TAG_SEARCH_NC_1_2 << @_elm_name << TAG_CLOSE
|
1435
|
+
@pattern_cc = "<#{@_elm_name}\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*>((?!(#{@_elm_name}[^<>]*>)).)*<\\/#{@_elm_name}>"
|
1431
1436
|
|
1432
1437
|
@elm_.pattern = @pattern_cc
|
1433
1438
|
#
|
@@ -1437,7 +1442,7 @@ module Meteor
|
|
1437
1442
|
|
1438
1443
|
elsif @res.captures.length == 6 then
|
1439
1444
|
|
1440
|
-
@elm_ = Element.new(
|
1445
|
+
@elm_ = Element.new(elm_name)
|
1441
1446
|
#属性
|
1442
1447
|
@elm_.attributes = @res[1].chop
|
1443
1448
|
#要素
|
@@ -1452,33 +1457,33 @@ module Meteor
|
|
1452
1457
|
@elm_.parser = self
|
1453
1458
|
end
|
1454
1459
|
end
|
1455
|
-
private :
|
1460
|
+
private :element_with_5_1
|
1456
1461
|
|
1457
|
-
def
|
1462
|
+
def element_with_5_2(elm_name)
|
1458
1463
|
|
1459
|
-
#@pattern_cc_1 = '' << TAG_OPEN << @
|
1460
|
-
#@pattern_cc_1 << @
|
1461
|
-
#@pattern_cc_1 << @
|
1462
|
-
#@pattern_cc_1 << @
|
1463
|
-
#@pattern_cc_1 << @
|
1464
|
-
@pattern_cc_1 = "<#{@
|
1464
|
+
#@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
1465
|
+
#@pattern_cc_1 << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
1466
|
+
#@pattern_cc_1 << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
1467
|
+
#@pattern_cc_1 << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
1468
|
+
#@pattern_cc_1 << @_attr_value1 << TAG_SEARCH_2_4_2_2
|
1469
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")([^<>\\/]*>|((?!([^<>]*\\/>))[^<>]*>)))"
|
1465
1470
|
|
1466
|
-
@pattern_cc_1b = '' << TAG_OPEN <<
|
1471
|
+
@pattern_cc_1b = '' << TAG_OPEN << elm_name << TAG_SEARCH_1_4
|
1467
1472
|
|
1468
|
-
#@pattern_cc_1_1 = '' << TAG_OPEN << @
|
1469
|
-
#@pattern_cc_1_1 << @
|
1470
|
-
#@pattern_cc_1_1 << @
|
1471
|
-
#@pattern_cc_1_1 << @
|
1472
|
-
#@pattern_cc_1_1 << @
|
1473
|
-
@pattern_cc_1 = "<#{@
|
1474
|
-
|
1475
|
-
@pattern_cc_1_2 = '' << TAG_SEARCH_4_2 << @
|
1473
|
+
#@pattern_cc_1_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
1474
|
+
#@pattern_cc_1_1 << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
1475
|
+
#@pattern_cc_1_1 << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
1476
|
+
#@pattern_cc_1_1 << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
1477
|
+
#@pattern_cc_1_1 << @_attr_value1 << TAG_SEARCH_4_7_2
|
1478
|
+
@pattern_cc_1 = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")(?:[^<>\\/]*>|(?!([^<>]*\\/>))[^<>]*>))("
|
1479
|
+
|
1480
|
+
@pattern_cc_1_2 = '' << TAG_SEARCH_4_2 << @_elm_name << TAG_SEARCH_4_3
|
1476
1481
|
|
1477
|
-
@pattern_cc_2 = '' << TAG_SEARCH_4_4 << @
|
1482
|
+
@pattern_cc_2 = '' << TAG_SEARCH_4_4 << @_elm_name << TAG_CLOSE
|
1478
1483
|
|
1479
|
-
@pattern_cc_2_1 = '' << TAG_SEARCH_4_5 << @
|
1484
|
+
@pattern_cc_2_1 = '' << TAG_SEARCH_4_5 << @_elm_name << TAG_CLOSE
|
1480
1485
|
|
1481
|
-
@pattern_cc_2_2 = '' << TAG_SEARCH_4_6 << @
|
1486
|
+
@pattern_cc_2_2 = '' << TAG_SEARCH_4_6 << @_elm_name << TAG_CLOSE
|
1482
1487
|
|
1483
1488
|
#内容あり要素検索
|
1484
1489
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc_1)
|
@@ -1495,7 +1500,7 @@ module Meteor
|
|
1495
1500
|
@pattern_cc = @sbuf
|
1496
1501
|
|
1497
1502
|
if @sbuf.length == 0 || @cnt != 0 then
|
1498
|
-
# raise NoSuchElementException.new(
|
1503
|
+
# raise NoSuchElementException.new(elm_name,attr_name1,attr_value1,attr_name2,attr_value2);
|
1499
1504
|
return nil
|
1500
1505
|
end
|
1501
1506
|
|
@@ -1504,64 +1509,64 @@ module Meteor
|
|
1504
1509
|
|
1505
1510
|
@res
|
1506
1511
|
end
|
1507
|
-
private :
|
1512
|
+
private :element_with_5_2
|
1508
1513
|
|
1509
|
-
def
|
1510
|
-
|
1514
|
+
def element_without_5(elm_name)
|
1515
|
+
element_without_5_1(elm_name,TAG_SEARCH_NC_2_3_2_2);
|
1511
1516
|
end
|
1512
|
-
private :
|
1517
|
+
private :element_without_5
|
1513
1518
|
|
1514
|
-
def
|
1519
|
+
def element_without_5_1(elm_name,closer)
|
1515
1520
|
|
1516
1521
|
#要素
|
1517
|
-
@elm_ = Element.new(
|
1522
|
+
@elm_ = Element.new(elm_name)
|
1518
1523
|
#属性
|
1519
1524
|
@elm_.attributes = @res[1]
|
1520
1525
|
#全体
|
1521
1526
|
@elm_.document = @res[0]
|
1522
1527
|
#空要素検索用パターン
|
1523
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
1524
|
-
#@pattern_cc << @
|
1525
|
-
#@pattern_cc << @
|
1526
|
-
#@pattern_cc << @
|
1527
|
-
#@pattern_cc << @
|
1528
|
-
@pattern_cc = "<#{@
|
1528
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_NC_2_1_2 << @_attr_name1 << ATTR_EQ
|
1529
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_NC_2_6 << @_attr_name2 << ATTR_EQ
|
1530
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_7 << @_attr_name2 << ATTR_EQ
|
1531
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_6 << @_attr_name1 << ATTR_EQ
|
1532
|
+
#@pattern_cc << @_attr_value1 << closer
|
1533
|
+
@pattern_cc = "<#{@_elm_name}\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}#{closer}"
|
1529
1534
|
|
1530
1535
|
@elm_.pattern = @pattern_cc
|
1531
1536
|
|
1532
1537
|
@elm_.parser = self
|
1533
1538
|
end
|
1534
|
-
private :
|
1539
|
+
private :element_without_5_1
|
1535
1540
|
|
1536
1541
|
#
|
1537
1542
|
# 属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
1538
1543
|
#
|
1539
|
-
# @param [String]
|
1540
|
-
# @param [String]
|
1541
|
-
# @param [String]
|
1542
|
-
# @param [String]
|
1544
|
+
# @param [String] attr_name1 属性名1
|
1545
|
+
# @param [String] attr_value1 属性値1
|
1546
|
+
# @param [String] attr_name2 属性名2
|
1547
|
+
# @param [String]attr_value2 属性値2
|
1543
1548
|
# @return [Meteor::Element] 要素
|
1544
1549
|
#
|
1545
|
-
def element_4(
|
1550
|
+
def element_4(attr_name1,attr_value1,attr_name2,attr_value2)
|
1546
1551
|
|
1547
|
-
@
|
1548
|
-
@
|
1549
|
-
@
|
1550
|
-
@
|
1552
|
+
@_attr_name1 = escape_regex(attr_name1)
|
1553
|
+
@_attr_name2 = escape_regex(attr_name2)
|
1554
|
+
@_attr_value1 = escape_regex(attr_value1)
|
1555
|
+
@_attr_value2 = escape_regex(attr_value2)
|
1551
1556
|
|
1552
|
-
#@pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @
|
1553
|
-
#@pattern_cc << @
|
1554
|
-
#@pattern_cc << @
|
1555
|
-
#@pattern_cc << @
|
1556
|
-
#@pattern_cc << @
|
1557
|
-
@pattern_cc = "<([^<>\"]*)\\s([^<>]*(#{@
|
1557
|
+
#@pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @_attr_name1 << ATTR_EQ
|
1558
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
1559
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
1560
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
1561
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_4_2_3
|
1562
|
+
@pattern_cc = "<([^<>\"]*)\\s([^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\""
|
1558
1563
|
|
1559
1564
|
@pattern = PatternCache.get(@pattern_cc)
|
1560
1565
|
|
1561
1566
|
@res = @pattern.match(@root.document)
|
1562
1567
|
|
1563
1568
|
if @res then
|
1564
|
-
@elm_ = element_5(@res[1],
|
1569
|
+
@elm_ = element_5(@res[1], attr_name1, attr_value1,attr_name2, attr_value2);
|
1565
1570
|
else
|
1566
1571
|
@elm_ = nil
|
1567
1572
|
end
|
@@ -1572,7 +1577,7 @@ module Meteor
|
|
1572
1577
|
|
1573
1578
|
def create_element_pattern
|
1574
1579
|
|
1575
|
-
if RUBY_VERSION >=
|
1580
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1576
1581
|
|
1577
1582
|
@position = 0
|
1578
1583
|
|
@@ -1773,19 +1778,19 @@ module Meteor
|
|
1773
1778
|
def attribute(*args)
|
1774
1779
|
case args.length
|
1775
1780
|
when 1
|
1776
|
-
|
1781
|
+
get_attribute_value_1(args[0])
|
1777
1782
|
when 2
|
1778
1783
|
if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
1779
|
-
|
1784
|
+
get_attribute_value_2(args[0],args[1])
|
1780
1785
|
elsif args[0].kind_of?(String) && args[1].kind_of?(String) then
|
1781
|
-
|
1786
|
+
set_attribute_2(args[0],args[1])
|
1782
1787
|
elsif args[0].kind_of?(Meteor::Element) && args[1].kind_of?(Meteor::AttributeMap) then
|
1783
|
-
|
1788
|
+
set_attribute_2_m(args[0],args[1])
|
1784
1789
|
else
|
1785
1790
|
raise ArgumentError
|
1786
1791
|
end
|
1787
1792
|
when 3
|
1788
|
-
|
1793
|
+
set_attribute_3(args[0],args[1],args[2])
|
1789
1794
|
else
|
1790
1795
|
raise ArgumentError
|
1791
1796
|
end
|
@@ -1795,18 +1800,18 @@ module Meteor
|
|
1795
1800
|
# 要素の属性を編集する
|
1796
1801
|
#
|
1797
1802
|
# @param [Meteor::Element] elm 要素
|
1798
|
-
# @param [String]
|
1799
|
-
# @param [String]
|
1803
|
+
# @param [String] attr_name 属性名
|
1804
|
+
# @param [String] attr_value 属性値
|
1800
1805
|
#
|
1801
|
-
def
|
1806
|
+
def set_attribute_3(elm,attr_name,attr_value)
|
1802
1807
|
if !elm.cx then
|
1803
|
-
|
1808
|
+
attr_value = escape(attr_value)
|
1804
1809
|
#属性群の更新
|
1805
|
-
|
1810
|
+
edit_attributes_(elm,attr_name,attr_value)
|
1806
1811
|
|
1807
1812
|
if !elm.parent then
|
1808
|
-
if elm.arguments.map.include?(
|
1809
|
-
elm.arguments.store(
|
1813
|
+
if elm.arguments.map.include?(attr_name) then
|
1814
|
+
elm.arguments.store(attr_name, attr_value)
|
1810
1815
|
end
|
1811
1816
|
|
1812
1817
|
@e_cache.store(elm.origin, elm)
|
@@ -1814,35 +1819,35 @@ module Meteor
|
|
1814
1819
|
end
|
1815
1820
|
elm
|
1816
1821
|
end
|
1817
|
-
private :
|
1822
|
+
private :set_attribute_3
|
1818
1823
|
|
1819
|
-
def
|
1824
|
+
def edit_attributes_(elm,attr_name,attr_value)
|
1820
1825
|
|
1821
1826
|
#属性検索
|
1822
1827
|
#@res = @pattern.match(elm.attributes)
|
1823
1828
|
|
1824
1829
|
#検索対象属性の存在判定
|
1825
1830
|
#if @res then
|
1826
|
-
if elm.attributes.include?(' ' <<
|
1831
|
+
if elm.attributes.include?(' ' << attr_name << ATTR_EQ) then
|
1827
1832
|
|
1828
|
-
@
|
1829
|
-
#
|
1830
|
-
if elm.parser.
|
1831
|
-
|
1833
|
+
@_attr_value = attr_value
|
1834
|
+
#replace2regex(@_attr_value)
|
1835
|
+
if elm.parser.root_element.hook || elm.parser.root_element.mono_hook then
|
1836
|
+
replace4regex(@_attr_value)
|
1832
1837
|
else
|
1833
|
-
|
1838
|
+
replace2regex(@_attr_value)
|
1834
1839
|
end
|
1835
1840
|
#属性の置換
|
1836
|
-
@pattern = Meteor::Core::Util::PatternCache.get('' <<
|
1841
|
+
@pattern = Meteor::Core::Util::PatternCache.get('' << attr_name << SET_ATTR_1)
|
1837
1842
|
|
1838
|
-
#elm.attributes.sub!(@pattern,'' <<
|
1839
|
-
elm.attributes.sub!(@pattern,"#{
|
1843
|
+
#elm.attributes.sub!(@pattern,'' << attr_name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION)
|
1844
|
+
elm.attributes.sub!(@pattern,"#{attr_name}=\"#{@_attr_value}\"")
|
1840
1845
|
else
|
1841
1846
|
#属性文字列の最後に新規の属性を追加する
|
1842
|
-
@
|
1843
|
-
#
|
1844
|
-
if elm.parser.
|
1845
|
-
|
1847
|
+
@_attr_value = attr_value
|
1848
|
+
#replace2regex(@_attr_value)
|
1849
|
+
if elm.parser.root_element.hook || elm.parser.root_element.mono_hook then
|
1850
|
+
replace2regex(@_attr_value)
|
1846
1851
|
end
|
1847
1852
|
|
1848
1853
|
if EMPTY != elm.attributes && EMPTY != elm.attributes.strip then
|
@@ -1851,31 +1856,31 @@ module Meteor
|
|
1851
1856
|
elm.attributes = ''
|
1852
1857
|
end
|
1853
1858
|
|
1854
|
-
#elm.attributes << SPACE <<
|
1855
|
-
elm.attributes << " #{
|
1859
|
+
#elm.attributes << SPACE << attr_name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION
|
1860
|
+
elm.attributes << " #{attr_name}=\"#{@_attr_value}\""
|
1856
1861
|
end
|
1857
1862
|
|
1858
1863
|
end
|
1859
|
-
private :
|
1864
|
+
private :edit_attributes_
|
1860
1865
|
|
1861
|
-
def
|
1862
|
-
|
1866
|
+
def edit_document_1(elm)
|
1867
|
+
edit_document_2(elm,TAG_CLOSE3)
|
1863
1868
|
end
|
1864
|
-
private :
|
1869
|
+
private :edit_document_1
|
1865
1870
|
|
1866
|
-
def
|
1871
|
+
def edit_document_2(elm,closer)
|
1867
1872
|
if !elm.cx then
|
1868
1873
|
@_attributes = elm.attributes
|
1869
|
-
|
1874
|
+
replace2regex(@_attributes)
|
1870
1875
|
|
1871
1876
|
if elm.empty then
|
1872
1877
|
#内容あり要素の場合
|
1873
1878
|
@_content = elm.mixed_content
|
1874
|
-
#
|
1875
|
-
if elm.parser.
|
1876
|
-
|
1879
|
+
#replace2regex(@_content)
|
1880
|
+
if elm.parser.root_element.hook || elm.parser.root_element.mono_hook then
|
1881
|
+
replace4regex(@_content)
|
1877
1882
|
else
|
1878
|
-
|
1883
|
+
replace2regex(@_content)
|
1879
1884
|
end
|
1880
1885
|
|
1881
1886
|
#タグ検索用パターン
|
@@ -1890,10 +1895,10 @@ module Meteor
|
|
1890
1895
|
end
|
1891
1896
|
else
|
1892
1897
|
@_content = elm.mixed_content
|
1893
|
-
if elm.parser.
|
1894
|
-
|
1898
|
+
if elm.parser.root_element.hook || elm.parser.root_element.mono_hook then
|
1899
|
+
replace4regex(@_content)
|
1895
1900
|
else
|
1896
|
-
|
1901
|
+
replace2regex(@_content)
|
1897
1902
|
end
|
1898
1903
|
|
1899
1904
|
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
@@ -1905,60 +1910,59 @@ module Meteor
|
|
1905
1910
|
@root.document.sub!(@pattern,@pattern_cc)
|
1906
1911
|
end
|
1907
1912
|
end
|
1908
|
-
private :
|
1913
|
+
private :edit_document_2
|
1909
1914
|
|
1910
|
-
def
|
1911
|
-
|
1912
|
-
elm.arguments.map.each{ |name,attr|
|
1915
|
+
def edit_pattern_(elm)
|
1913
1916
|
|
1917
|
+
elm.arguments.map.each do |name, attr|
|
1914
1918
|
if attr.changed then
|
1915
|
-
@
|
1916
|
-
#
|
1919
|
+
@_attr_value = escape_regex(attr.value)
|
1920
|
+
#replace2regex(@_attr_value)
|
1917
1921
|
#@pattern_cc = '' << name << SET_ATTR_1
|
1918
|
-
@pattern_cc = "#{
|
1922
|
+
@pattern_cc = "#{attr.name}=\"[^\"]*\""
|
1919
1923
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
1920
|
-
#elm.pattern.gsub!(@pattern,'' << name << ATTR_EQ << @
|
1921
|
-
elm.pattern.sub!(@pattern,"#{
|
1924
|
+
#elm.pattern.gsub!(@pattern,'' << name << ATTR_EQ << @_attr_value << DOUBLE_QUATATION)
|
1925
|
+
elm.pattern.sub!(@pattern, "#{attr.name}=\"#{@_attr_value}\"")
|
1922
1926
|
elsif attr.removed then
|
1923
1927
|
@pattern_cc = '' << name << SET_ATTR_1
|
1924
|
-
#@pattern_cc = "#{
|
1928
|
+
#@pattern_cc = "#{attr_name}=\"[^\"]*\""
|
1925
1929
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
1926
|
-
elm.pattern.gsub!(@pattern,EMPTY)
|
1930
|
+
elm.pattern.gsub!(@pattern, EMPTY)
|
1927
1931
|
end
|
1928
|
-
|
1932
|
+
end
|
1929
1933
|
end
|
1930
|
-
private :
|
1934
|
+
private :edit_pattern_
|
1931
1935
|
|
1932
1936
|
#
|
1933
1937
|
# 要素の属性を編集する
|
1934
1938
|
#
|
1935
|
-
# @param [String]
|
1936
|
-
# @param [String]
|
1939
|
+
# @param [String] attr_name 属性名
|
1940
|
+
# @param [String] attr_value 属性値
|
1937
1941
|
#
|
1938
|
-
def
|
1939
|
-
if @root.hook || @root.
|
1940
|
-
|
1942
|
+
def set_attribute_2(attr_name,attr_value)
|
1943
|
+
if @root.hook || @root.mono_hook then
|
1944
|
+
set_attribute_3(@root.mutableElement, attr_name, attr_value)
|
1941
1945
|
end
|
1942
1946
|
@root.mutableElement
|
1943
1947
|
end
|
1944
|
-
private :
|
1948
|
+
private :set_attribute_2
|
1945
1949
|
|
1946
1950
|
#
|
1947
1951
|
# 要素の属性値を取得する
|
1948
1952
|
#
|
1949
1953
|
# @param [Meteor::Element] elm 要素
|
1950
|
-
# @param [String]
|
1954
|
+
# @param [String] attr_name 属性名
|
1951
1955
|
# @return [String] 属性値
|
1952
1956
|
#
|
1953
|
-
def
|
1954
|
-
|
1957
|
+
def get_attribute_value_2(elm,attr_name)
|
1958
|
+
get_attribute_value_(elm,attr_name)
|
1955
1959
|
end
|
1956
|
-
private :
|
1960
|
+
private :get_attribute_value_2
|
1957
1961
|
|
1958
|
-
def
|
1962
|
+
def get_attribute_value_(elm,attr_name)
|
1959
1963
|
|
1960
1964
|
#属性検索用パターン
|
1961
|
-
@pattern = Meteor::Core::Util::PatternCache.get('' <<
|
1965
|
+
@pattern = Meteor::Core::Util::PatternCache.get('' << attr_name << GET_ATTR_1)
|
1962
1966
|
|
1963
1967
|
@res = @pattern.match(elm.attributes)
|
1964
1968
|
|
@@ -1968,22 +1972,22 @@ module Meteor
|
|
1968
1972
|
nil
|
1969
1973
|
end
|
1970
1974
|
end
|
1971
|
-
private :
|
1975
|
+
private :get_attribute_value_
|
1972
1976
|
|
1973
1977
|
#
|
1974
1978
|
# 要素の属性値を取得する
|
1975
1979
|
#
|
1976
|
-
# @param [String]
|
1980
|
+
# @param [String] attr_name 属性名
|
1977
1981
|
# @return [String] 属性値
|
1978
1982
|
#
|
1979
|
-
def
|
1980
|
-
if @root.hook || @root.
|
1981
|
-
|
1983
|
+
def get_attribute_value_1(attr_name)
|
1984
|
+
if @root.hook || @root.mono_hook then
|
1985
|
+
get_attribute_value_2(@root.mutableElement, attr_name)
|
1982
1986
|
else
|
1983
1987
|
nil
|
1984
1988
|
end
|
1985
1989
|
end
|
1986
|
-
private :
|
1990
|
+
private :get_attribute_value_1
|
1987
1991
|
|
1988
1992
|
#
|
1989
1993
|
# 属性マップを取得する
|
@@ -1991,12 +1995,12 @@ module Meteor
|
|
1991
1995
|
# @param [Array] args 引数配列
|
1992
1996
|
# @return [Meteor::AttributeMap] 属性マップ
|
1993
1997
|
#
|
1994
|
-
def
|
1998
|
+
def attribute_map(*args)
|
1995
1999
|
case args.length
|
1996
2000
|
when 0
|
1997
|
-
|
2001
|
+
get_attribute_map_0
|
1998
2002
|
when 1
|
1999
|
-
|
2003
|
+
get_attribute_map_1(args[0])
|
2000
2004
|
else
|
2001
2005
|
raise ArgumentError
|
2002
2006
|
end
|
@@ -2008,31 +2012,31 @@ module Meteor
|
|
2008
2012
|
# @param [Meteor::Element] elm 要素
|
2009
2013
|
# @return [Meteor::AttributeMap] 属性マップ
|
2010
2014
|
#
|
2011
|
-
def
|
2015
|
+
def get_attribute_map_1(elm)
|
2012
2016
|
attrs = Meteor::AttributeMap.new
|
2013
2017
|
|
2014
|
-
elm.attributes.scan(@@pattern_get_attrs_map)
|
2015
|
-
attrs.store(a,unescape(b))
|
2016
|
-
|
2018
|
+
elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
|
2019
|
+
attrs.store(a, unescape(b))
|
2020
|
+
end
|
2017
2021
|
attrs.recordable = true
|
2018
2022
|
|
2019
2023
|
attrs
|
2020
2024
|
end
|
2021
|
-
private :
|
2025
|
+
private :get_attribute_map_1
|
2022
2026
|
|
2023
2027
|
#
|
2024
2028
|
# 要素の属性マップを取得する
|
2025
2029
|
#
|
2026
2030
|
# @return [Meteor::AttributeMap] 属性マップ
|
2027
2031
|
#
|
2028
|
-
def
|
2029
|
-
if @root.hook || @root.
|
2030
|
-
|
2032
|
+
def get_attribute_map_0()
|
2033
|
+
if @root.hook || @root.mono_hook then
|
2034
|
+
get_attribute_map_1(@root.mutableElement)
|
2031
2035
|
else
|
2032
2036
|
nil
|
2033
2037
|
end
|
2034
2038
|
end
|
2035
|
-
private :
|
2039
|
+
private :get_attribute_map_0
|
2036
2040
|
|
2037
2041
|
#
|
2038
2042
|
# 要素の属性を編集する
|
@@ -2040,15 +2044,15 @@ module Meteor
|
|
2040
2044
|
# @param [Meteor::Element] elm 要素
|
2041
2045
|
# @param [Meteor::AttributeMap] attrMap 属性マップ
|
2042
2046
|
#
|
2043
|
-
def
|
2047
|
+
def set_attribute_2_m(elm,attr_map)
|
2044
2048
|
if !elm.cx then
|
2045
|
-
|
2046
|
-
if
|
2047
|
-
|
2048
|
-
elsif
|
2049
|
-
|
2049
|
+
attr_map.map.each do |name, attr|
|
2050
|
+
if attr_map.changed(name) then
|
2051
|
+
edit_attributes_(elm, name, attr.value)
|
2052
|
+
elsif attr_map.removed(name) then
|
2053
|
+
remove_attributes_(elm, name)
|
2050
2054
|
end
|
2051
|
-
|
2055
|
+
end
|
2052
2056
|
|
2053
2057
|
if !elm.parent then
|
2054
2058
|
@e_cache.store(elm.origin,elm)
|
@@ -2056,7 +2060,7 @@ module Meteor
|
|
2056
2060
|
end
|
2057
2061
|
elm
|
2058
2062
|
end
|
2059
|
-
private :
|
2063
|
+
private :set_attribute_2_m
|
2060
2064
|
|
2061
2065
|
#
|
2062
2066
|
# 要素の内容をセットする or 内容を取得する
|
@@ -2068,20 +2072,20 @@ module Meteor
|
|
2068
2072
|
case args.length
|
2069
2073
|
when 1
|
2070
2074
|
if args[0].kind_of?(Meteor::Element) then
|
2071
|
-
|
2075
|
+
get_content_1(args[0])
|
2072
2076
|
elsif args[0].kind_of?(String) then
|
2073
|
-
|
2077
|
+
set_content_1(args[0])
|
2074
2078
|
end
|
2075
2079
|
when 2
|
2076
2080
|
if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
2077
|
-
|
2078
|
-
elsif args[0].kind_of?(String) && (args[1].kind_of?(TrueClass) || args[1].kind_of?(
|
2079
|
-
|
2081
|
+
set_content_2_s(args[0],args[1])
|
2082
|
+
elsif args[0].kind_of?(String) && (args[1].kind_of?(TrueClass) || args[1].kind_of?(FalseClass)) then
|
2083
|
+
set_content_2_b(args[0],args[1])
|
2080
2084
|
else
|
2081
2085
|
raise ArgumentError
|
2082
2086
|
end
|
2083
2087
|
when 3
|
2084
|
-
|
2088
|
+
set_content_3(args[0],args[1],args[2])
|
2085
2089
|
else
|
2086
2090
|
raise ArgumentError
|
2087
2091
|
end
|
@@ -2094,10 +2098,10 @@ module Meteor
|
|
2094
2098
|
# @param [String] mixed_content 要素の内容
|
2095
2099
|
# @param [TrueClass][FalseClass] entityRef エンティティ参照フラグ
|
2096
2100
|
#
|
2097
|
-
def
|
2101
|
+
def set_content_3(elm,content,entity_ref=true)
|
2098
2102
|
|
2099
|
-
if
|
2100
|
-
content =
|
2103
|
+
if entity_ref then
|
2104
|
+
content = escape_content(content,elm.name)
|
2101
2105
|
end
|
2102
2106
|
|
2103
2107
|
elm.mixed_content = content
|
@@ -2108,7 +2112,7 @@ module Meteor
|
|
2108
2112
|
|
2109
2113
|
elm
|
2110
2114
|
end
|
2111
|
-
private :
|
2115
|
+
private :set_content_3
|
2112
2116
|
|
2113
2117
|
#
|
2114
2118
|
# 要素の内容を編集する
|
@@ -2116,60 +2120,60 @@ module Meteor
|
|
2116
2120
|
# @param [Meteor::Element] 要素
|
2117
2121
|
# @param [String] mixed_content 要素の内容
|
2118
2122
|
#
|
2119
|
-
def
|
2120
|
-
|
2123
|
+
def set_content_2_s(elm,content)
|
2124
|
+
set_content_3(elm, content)
|
2121
2125
|
end
|
2122
|
-
private :
|
2126
|
+
private :set_content_2_s
|
2123
2127
|
|
2124
2128
|
#
|
2125
2129
|
# 要素の内容を編集する
|
2126
2130
|
#
|
2127
2131
|
# @param [String] mixed_content 内容
|
2128
2132
|
#
|
2129
|
-
def
|
2130
|
-
if @root.
|
2131
|
-
|
2133
|
+
def set_content_1(content)
|
2134
|
+
if @root.mono_hook then
|
2135
|
+
set_content_2_s(@root.mutableElement, content)
|
2132
2136
|
end
|
2133
2137
|
end
|
2134
|
-
private :
|
2138
|
+
private :set_content_1
|
2135
2139
|
|
2136
2140
|
#
|
2137
2141
|
# 要素の内容を編集する
|
2138
2142
|
#
|
2139
2143
|
# @param [String] mixed_content 内容
|
2140
|
-
# @param [TrueClass][FalseClass]
|
2144
|
+
# @param [TrueClass][FalseClass] entity_ref エンティティ参照フラグ
|
2141
2145
|
#
|
2142
|
-
def
|
2143
|
-
if @root.
|
2144
|
-
|
2146
|
+
def set_content_2_b(content,entity_ref)
|
2147
|
+
if @root.mono_hook then
|
2148
|
+
set_content_3(@root.mutableElement, content, entity_ref)
|
2145
2149
|
end
|
2146
2150
|
|
2147
|
-
|
2151
|
+
@root.mutableElement
|
2148
2152
|
end
|
2149
|
-
private :
|
2153
|
+
private :set_content_2_b
|
2150
2154
|
|
2151
|
-
def
|
2155
|
+
def get_content_1(elm)
|
2152
2156
|
if !elm.cx then
|
2153
2157
|
if elm.empty then
|
2154
|
-
|
2158
|
+
unescape_content(elm.mixed_content,elm.name)
|
2155
2159
|
end
|
2156
2160
|
else
|
2157
2161
|
nil
|
2158
2162
|
end
|
2159
2163
|
end
|
2160
|
-
private :
|
2164
|
+
private :get_content_1
|
2161
2165
|
|
2162
2166
|
#
|
2163
2167
|
# 要素の属性を消す
|
2164
2168
|
#
|
2165
2169
|
# @param [Array] args 引数配列
|
2166
2170
|
#
|
2167
|
-
def
|
2171
|
+
def remove_attribute(*args)
|
2168
2172
|
case args.length
|
2169
2173
|
when 1
|
2170
|
-
|
2174
|
+
remove_attribute_1(args[0])
|
2171
2175
|
when 2
|
2172
|
-
|
2176
|
+
remove_attribute_2(args[0],args[1])
|
2173
2177
|
else
|
2174
2178
|
raise ArgumentError
|
2175
2179
|
end
|
@@ -2179,16 +2183,16 @@ module Meteor
|
|
2179
2183
|
# 要素の属性を消す
|
2180
2184
|
#
|
2181
2185
|
# @param [Meteor::Element] elm 要素
|
2182
|
-
# @param [String]
|
2186
|
+
# @param [String] attr_name 属性名
|
2183
2187
|
#
|
2184
|
-
def
|
2188
|
+
def remove_attribute_2(elm,attr_name)
|
2185
2189
|
if !elm.cx then
|
2186
2190
|
|
2187
|
-
|
2191
|
+
remove_attributes_(elm,attr_name)
|
2188
2192
|
|
2189
2193
|
if !elm.parent then
|
2190
|
-
if elm.arguments.map.include?(
|
2191
|
-
elm.arguments.delete(
|
2194
|
+
if elm.arguments.map.include?(attr_name) then
|
2195
|
+
elm.arguments.delete(attr_name)
|
2192
2196
|
end
|
2193
2197
|
|
2194
2198
|
@e_cache.store(elm.origin,elm)
|
@@ -2197,36 +2201,36 @@ module Meteor
|
|
2197
2201
|
|
2198
2202
|
elm
|
2199
2203
|
end
|
2200
|
-
private :
|
2204
|
+
private :remove_attribute_2
|
2201
2205
|
|
2202
|
-
def
|
2206
|
+
def remove_attributes_(elm,attr_name)
|
2203
2207
|
#属性検索用パターン
|
2204
|
-
@pattern = Meteor::Core::Util::PatternCache.get('' <<
|
2208
|
+
@pattern = Meteor::Core::Util::PatternCache.get('' << attr_name << ERASE_ATTR_1)
|
2205
2209
|
#属性の置換
|
2206
2210
|
elm.attributes.sub!(@pattern,EMPTY)
|
2207
2211
|
end
|
2208
|
-
private :
|
2212
|
+
private :remove_attributes_
|
2209
2213
|
|
2210
2214
|
#
|
2211
2215
|
# 要素の属性を消す
|
2212
2216
|
#
|
2213
|
-
# @param [String]
|
2217
|
+
# @param [String] attr_name 属性名
|
2214
2218
|
#
|
2215
|
-
def
|
2216
|
-
if @root.hook || @root.
|
2217
|
-
|
2219
|
+
def remove_attribute_1(attr_name)
|
2220
|
+
if @root.hook || @root.mono_hook then
|
2221
|
+
remove_attribute_2(@root.mutableElement, attr_name)
|
2218
2222
|
end
|
2219
2223
|
|
2220
2224
|
@root.mutableElement
|
2221
2225
|
end
|
2222
|
-
private :
|
2226
|
+
private :remove_attribute_1
|
2223
2227
|
|
2224
2228
|
#
|
2225
2229
|
# 要素を消す
|
2226
2230
|
#
|
2227
2231
|
# @param [Meteor::Element] elm 要素
|
2228
2232
|
#
|
2229
|
-
def
|
2233
|
+
def remove_element(elm)
|
2230
2234
|
replace(elm,EMPTY)
|
2231
2235
|
@e_cache.delete(elm.origin)
|
2232
2236
|
end
|
@@ -2251,16 +2255,16 @@ module Meteor
|
|
2251
2255
|
#
|
2252
2256
|
# 要素名とID属性で検索し、CX(コメント拡張)タグを取得する
|
2253
2257
|
#
|
2254
|
-
# @param [String]
|
2258
|
+
# @param [String] elm_name 要素名
|
2255
2259
|
# @param [String] id ID属性値
|
2256
2260
|
# @return [Meteor::Element] 要素
|
2257
2261
|
#
|
2258
|
-
def cxtag_2(
|
2262
|
+
def cxtag_2(elm_name,id)
|
2259
2263
|
|
2260
2264
|
#CXタグ検索用パターン
|
2261
|
-
#@pattern_cc = '' << SEARCH_CX_1 <<
|
2262
|
-
#@pattern_cc << id << SEARCH_CX_3 <<
|
2263
|
-
@pattern_cc = "<!--\\s@#{
|
2265
|
+
#@pattern_cc = '' << SEARCH_CX_1 << elm_name << SEARCH_CX_2
|
2266
|
+
#@pattern_cc << id << SEARCH_CX_3 << elm_name << SEARCH_CX_4 << elm_name << SEARCH_CX_5
|
2267
|
+
@pattern_cc = "<!--\\s@#{elm_name}\\s([^<>]*id=\"#{id}\"[^<>]*)-->(((?!(<!--\\s\\/@#{elm_name})).)*)<!--\\s\\/@#{elm_name}\\s-->"
|
2264
2268
|
|
2265
2269
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
2266
2270
|
#CXタグ検索
|
@@ -2268,7 +2272,7 @@ module Meteor
|
|
2268
2272
|
|
2269
2273
|
if @res then
|
2270
2274
|
#要素
|
2271
|
-
@elm_ = Element.new(
|
2275
|
+
@elm_ = Element.new(elm_name)
|
2272
2276
|
|
2273
2277
|
@elm_.cx = true
|
2274
2278
|
#属性
|
@@ -2321,26 +2325,26 @@ module Meteor
|
|
2321
2325
|
# @param [Meteor::Element] elm 要素
|
2322
2326
|
# @param [String] replaceDocument 置換文字列
|
2323
2327
|
#
|
2324
|
-
def replace(elm,
|
2328
|
+
def replace(elm,replace_document)
|
2325
2329
|
#文字エスケープ
|
2326
|
-
if
|
2327
|
-
|
2330
|
+
if replace_document.size > 0 && elm.parent && elm.mono then
|
2331
|
+
replace2regex(replace_document)
|
2328
2332
|
end
|
2329
2333
|
#タグ置換パターン
|
2330
2334
|
@pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
|
2331
2335
|
#タグ置換
|
2332
|
-
@root.document.sub!(@pattern,
|
2336
|
+
@root.document.sub!(@pattern,replace_document)
|
2333
2337
|
end
|
2334
2338
|
|
2335
2339
|
def reflect()
|
2336
2340
|
|
2337
|
-
@e_cache.values.each
|
2341
|
+
@e_cache.values.each do |item|
|
2338
2342
|
if item.usable == 0 then
|
2339
|
-
|
2340
|
-
|
2343
|
+
edit_document_1(item)
|
2344
|
+
edit_pattern_(item)
|
2341
2345
|
item.usable = 1
|
2342
2346
|
end
|
2343
|
-
|
2347
|
+
end
|
2344
2348
|
#@e_cache.clear
|
2345
2349
|
end
|
2346
2350
|
protected :reflect
|
@@ -2353,34 +2357,34 @@ module Meteor
|
|
2353
2357
|
|
2354
2358
|
if @root.hook then
|
2355
2359
|
@_attributes = @root.mutableElement.attributes
|
2356
|
-
|
2360
|
+
replace2regex(@_attributes)
|
2357
2361
|
if @root.element.cx then
|
2358
2362
|
#@root.hookDocument << SET_CX_1 << @root.mutableElement.name << SPACE
|
2359
2363
|
#@root.hookDocument << @_attributes << SET_CX_2
|
2360
2364
|
#@root.hookDocument << @root.document << SET_CX_3
|
2361
2365
|
#@root.hookDocument << @root.mutableElement.name << SET_CX_4
|
2362
|
-
@root.
|
2366
|
+
@root.hook_document << "<!-- @#{@root.mutableElement.name} #{@_attributes}-->#{@root.document}<!-- /@#{@root.mutableElement.name} -->"
|
2363
2367
|
else
|
2364
2368
|
#@root.hookDocument << TAG_OPEN << @root.mutableElement.name
|
2365
2369
|
#@root.hookDocument << @_attributes << TAG_CLOSE << @root.document
|
2366
2370
|
#@root.hookDocument << TAG_OPEN3 << @root.mutableElement.name << TAG_CLOSE
|
2367
|
-
@root.
|
2371
|
+
@root.hook_document << "<#{@root.mutableElement.name}#{@_attributes}>#{@root.document}</#{@root.mutableElement.name}>"
|
2368
2372
|
end
|
2369
|
-
@root.mutableElement = Element.
|
2373
|
+
@root.mutableElement = Element.new?(@root.element)
|
2370
2374
|
@root.document = String.new(@root.element.mixed_content)
|
2371
2375
|
else
|
2372
|
-
if @root.
|
2376
|
+
if @root.mono_hook then
|
2373
2377
|
if @root.element.cx then
|
2374
2378
|
#@root.hookDocument << SET_CX_1 << @root.mutableElement.name << SPACE
|
2375
2379
|
#@root.hookDocument << @root.mutableElement.attributes << SET_CX_2
|
2376
2380
|
#@root.hookDocument << @root.mutableElement.mixed_content << SET_CX_3
|
2377
2381
|
#@root.hookDocument << @root.mutableElement.name << SET_CX_4
|
2378
|
-
@root.
|
2382
|
+
@root.hook_document << "<!-- @#{@root.mutableElement.name} #{@root.mutableElement.attributes}-->#{@root.mutableElement.mixed_content}<!-- /@#{@root.mutableElement.name} -->"
|
2379
2383
|
else
|
2380
2384
|
#@root.hookDocument << TAG_OPEN << @root.mutableElement.name
|
2381
2385
|
#@root.hookDocument << @root.mutableElement.attributes << TAG_CLOSE << @root.mutableElement.mixed_content
|
2382
2386
|
#@root.hookDocument << TAG_OPEN3 << @root.mutableElement.name << TAG_CLOSE
|
2383
|
-
@root.
|
2387
|
+
@root.hook_document << "<#{@root.mutableElement.name}#{@root.mutableElement.attributes}>#{@root.mutableElement.mixed_content}</#{@root.mutableElement.name}>"
|
2384
2388
|
end
|
2385
2389
|
@root.mutableElement = Element.copy(@root.element)
|
2386
2390
|
else
|
@@ -2410,41 +2414,41 @@ module Meteor
|
|
2410
2414
|
def child(elm)
|
2411
2415
|
if elm.empty then
|
2412
2416
|
#内容あり要素の場合
|
2413
|
-
|
2417
|
+
set_mono_info(elm)
|
2414
2418
|
|
2415
2419
|
pif2 = create(self)
|
2416
2420
|
|
2417
2421
|
elm.parent=true
|
2418
2422
|
pif2.parent = self
|
2419
|
-
pif2.
|
2420
|
-
pif2.
|
2421
|
-
pif2.
|
2423
|
+
pif2.root_element.element = elm
|
2424
|
+
pif2.root_element.mutableElement = Element.new(elm)
|
2425
|
+
pif2.root_element.kaigyo_code = @root.kaigyo_code
|
2422
2426
|
|
2423
2427
|
if elm.mono then
|
2424
|
-
pif2.
|
2428
|
+
pif2.root_element.mono_hook = true
|
2425
2429
|
|
2426
2430
|
pif2
|
2427
2431
|
else
|
2428
|
-
pif2.
|
2429
|
-
pif2.
|
2432
|
+
pif2.root_element.document = String.new(elm.mixed_content)
|
2433
|
+
pif2.root_element.hook = true
|
2430
2434
|
|
2431
2435
|
pif2
|
2432
2436
|
end
|
2433
2437
|
end
|
2434
2438
|
end
|
2435
2439
|
|
2436
|
-
def
|
2440
|
+
def set_mono_info(elm)
|
2437
2441
|
end
|
2438
|
-
private :
|
2442
|
+
private :set_mono_info
|
2439
2443
|
|
2440
2444
|
#
|
2441
2445
|
# 反映する
|
2442
2446
|
#
|
2443
2447
|
def flush
|
2444
|
-
if @root.hook || @root.
|
2448
|
+
if @root.hook || @root.mono_hook then
|
2445
2449
|
if @root.element then
|
2446
|
-
@
|
2447
|
-
@
|
2450
|
+
@root.element.parser.reflect
|
2451
|
+
@root.element.parser.replace(@root.element, @root.hook_document)
|
2448
2452
|
end
|
2449
2453
|
end
|
2450
2454
|
end
|
@@ -2464,12 +2468,12 @@ module Meteor
|
|
2464
2468
|
end
|
2465
2469
|
|
2466
2470
|
def execute_2(elm,hook)
|
2467
|
-
hook.
|
2471
|
+
hook.do_action(elm, self)
|
2468
2472
|
end
|
2469
2473
|
private :execute_2
|
2470
2474
|
|
2471
2475
|
def execute_3(elm,loop,list)
|
2472
|
-
loop.
|
2476
|
+
loop.do_action(elm, self, list)
|
2473
2477
|
end
|
2474
2478
|
private :execute_3
|
2475
2479
|
|
@@ -2479,7 +2483,7 @@ module Meteor
|
|
2479
2483
|
# @param [String] element 入力文字列
|
2480
2484
|
# @return [String] 出力文字列
|
2481
2485
|
#
|
2482
|
-
def
|
2486
|
+
def escape_regex(element)
|
2483
2487
|
##「\」->[\\]
|
2484
2488
|
#element.gsub!(@@pattern_en,EN_2)
|
2485
2489
|
##「$」->「\$」
|
@@ -2510,21 +2514,21 @@ module Meteor
|
|
2510
2514
|
Regexp.quote(element)
|
2511
2515
|
|
2512
2516
|
end
|
2513
|
-
private :
|
2517
|
+
private :escape_regex
|
2514
2518
|
|
2515
|
-
def
|
2519
|
+
def replace2regex(element)
|
2516
2520
|
if element.include?(EN_1) then
|
2517
2521
|
element.gsub!(@@pattern_sub_regex1,SUB_REGEX2)
|
2518
2522
|
end
|
2519
2523
|
end
|
2520
|
-
private :
|
2524
|
+
private :replace2regex
|
2521
2525
|
|
2522
|
-
def
|
2526
|
+
def replace4regex(element)
|
2523
2527
|
if element.include?(EN_1) then
|
2524
2528
|
element.gsub!(@@pattern_sub_regex1,SUB_REGEX3)
|
2525
2529
|
end
|
2526
2530
|
end
|
2527
|
-
private :
|
2531
|
+
private :replace4regex
|
2528
2532
|
|
2529
2533
|
#
|
2530
2534
|
# @param [String] element 入力文字列
|
@@ -2537,13 +2541,13 @@ module Meteor
|
|
2537
2541
|
|
2538
2542
|
#
|
2539
2543
|
# @param [String] element 入力文字列
|
2540
|
-
# @param [String]
|
2544
|
+
# @param [String] elm_name 要素名
|
2541
2545
|
# @return [String] 出力文字列
|
2542
2546
|
#
|
2543
|
-
def
|
2547
|
+
def escape_content(element,elm_name)
|
2544
2548
|
element
|
2545
2549
|
end
|
2546
|
-
private :
|
2550
|
+
private :escape_content
|
2547
2551
|
|
2548
2552
|
#
|
2549
2553
|
# @param [String] element 入力文字列
|
@@ -2556,15 +2560,15 @@ module Meteor
|
|
2556
2560
|
|
2557
2561
|
#
|
2558
2562
|
# @param [String] element 入力文字列
|
2559
|
-
# @param [String]
|
2563
|
+
# @param [String] elm_name 要素名
|
2560
2564
|
# @return [String] 出力文字列
|
2561
2565
|
#
|
2562
|
-
def
|
2566
|
+
def unescape_content(element,elm_name)
|
2563
2567
|
element;
|
2564
2568
|
end
|
2565
|
-
private :
|
2569
|
+
private :unescape_content
|
2566
2570
|
|
2567
|
-
def
|
2571
|
+
def is_match(regex,str)
|
2568
2572
|
if regex.kind_of?(Regexp) then
|
2569
2573
|
if regex.match(str.downcase) then
|
2570
2574
|
true
|
@@ -2573,11 +2577,11 @@ module Meteor
|
|
2573
2577
|
end
|
2574
2578
|
elsif regex.kind_of?(Array) then
|
2575
2579
|
str = str.downcase
|
2576
|
-
regex.each
|
2580
|
+
regex.each do |item|
|
2577
2581
|
if item.eql?(str) then
|
2578
2582
|
return true
|
2579
2583
|
end
|
2580
|
-
|
2584
|
+
end
|
2581
2585
|
return false
|
2582
2586
|
elsif regex.kind_of?(String) then
|
2583
2587
|
if regex.eql?(str.downcase) then
|
@@ -2589,7 +2593,7 @@ module Meteor
|
|
2589
2593
|
raise ArgumentError
|
2590
2594
|
end
|
2591
2595
|
end
|
2592
|
-
private :
|
2596
|
+
private :is_match
|
2593
2597
|
|
2594
2598
|
|
2595
2599
|
def create(pif)
|
@@ -2639,7 +2643,7 @@ module Meteor
|
|
2639
2643
|
# パターンキャッシュクラス
|
2640
2644
|
#
|
2641
2645
|
class PatternCache
|
2642
|
-
@@
|
2646
|
+
@@regex_cache = Hash.new
|
2643
2647
|
|
2644
2648
|
#
|
2645
2649
|
# イニシャライザ
|
@@ -2664,24 +2668,24 @@ module Meteor
|
|
2664
2668
|
# @return [Regexp] パターン
|
2665
2669
|
#
|
2666
2670
|
def self.get_1(regex)
|
2667
|
-
#pattern = @@
|
2671
|
+
#pattern = @@regex_cache[regex]
|
2668
2672
|
#
|
2669
2673
|
#if pattern == nil then
|
2670
2674
|
if regex.kind_of?(String) then
|
2671
|
-
if !@@
|
2675
|
+
if !@@regex_cache[regex.to_sym] then
|
2672
2676
|
#pattern = Regexp.new(regex)
|
2673
|
-
#@@
|
2674
|
-
@@
|
2677
|
+
#@@regex_cache[regex] = pattern
|
2678
|
+
@@regex_cache[regex.to_sym] = Regexp.new(regex,Regexp::MULTILINE)
|
2675
2679
|
end
|
2676
2680
|
|
2677
2681
|
#return pattern
|
2678
|
-
@@
|
2682
|
+
@@regex_cache[regex.to_sym]
|
2679
2683
|
elsif regex.kind_of?(Symbol) then
|
2680
|
-
if !@@
|
2681
|
-
@@
|
2684
|
+
if !@@regex_cache[regex] then
|
2685
|
+
@@regex_cache[regex] = Regexp.new(regex.to_s,Regexp::MULTILINE)
|
2682
2686
|
end
|
2683
2687
|
|
2684
|
-
@@
|
2688
|
+
@@regex_cache[regex]
|
2685
2689
|
end
|
2686
2690
|
end
|
2687
2691
|
|
@@ -2691,24 +2695,24 @@ module Meteor
|
|
2691
2695
|
# @return [Regexp] パターン
|
2692
2696
|
#
|
2693
2697
|
def self.get_2(regex,option)
|
2694
|
-
#pattern = @@
|
2698
|
+
#pattern = @@regex_cache[regex]
|
2695
2699
|
#
|
2696
2700
|
#if pattern == nil then
|
2697
2701
|
if regex.kind_of?(String) then
|
2698
|
-
if !@@
|
2702
|
+
if !@@regex_cache[regex.to_sym] then
|
2699
2703
|
#pattern = Regexp.new(regex)
|
2700
|
-
#@@
|
2701
|
-
@@
|
2704
|
+
#@@regex_cache[regex] = pattern
|
2705
|
+
@@regex_cache[regex.to_sym] = Regexp.new(regex,option)
|
2702
2706
|
end
|
2703
2707
|
|
2704
2708
|
#return pattern
|
2705
|
-
@@
|
2709
|
+
@@regex_cache[regex.to_sym]
|
2706
2710
|
elsif regex.kind_of?(Symbol) then
|
2707
|
-
if !@@
|
2708
|
-
@@
|
2711
|
+
if !@@regex_cache[regex] then
|
2712
|
+
@@regex_cache[regex] = Regexp.new(regex.to_s,option)
|
2709
2713
|
end
|
2710
2714
|
|
2711
|
-
@@
|
2715
|
+
@@regex_cache[regex]
|
2712
2716
|
end
|
2713
2717
|
end
|
2714
2718
|
end
|
@@ -2753,30 +2757,30 @@ module Meteor
|
|
2753
2757
|
end
|
2754
2758
|
|
2755
2759
|
def each
|
2756
|
-
@keys.each
|
2760
|
+
@keys.each do |k|
|
2757
2761
|
arr_tmp = Array.new
|
2758
2762
|
arr_tmp << k
|
2759
2763
|
arr_tmp << self[k]
|
2760
2764
|
yield(arr_tmp)
|
2761
|
-
|
2765
|
+
end
|
2762
2766
|
return self
|
2763
2767
|
end
|
2764
2768
|
|
2765
2769
|
def each_pair
|
2766
|
-
@keys.each
|
2770
|
+
@keys.each do |k|
|
2767
2771
|
yield(k, self[k])
|
2768
|
-
|
2772
|
+
end
|
2769
2773
|
return self
|
2770
2774
|
end
|
2771
2775
|
|
2772
2776
|
def map
|
2773
2777
|
arr_tmp = Array.new
|
2774
|
-
@keys.each
|
2778
|
+
@keys.each do |k|
|
2775
2779
|
arg_arr = Array.new
|
2776
2780
|
arg_arr << k
|
2777
2781
|
arg_arr << self[k]
|
2778
2782
|
arr_tmp << yield(arg_arr)
|
2779
|
-
|
2783
|
+
end
|
2780
2784
|
return arr_tmp
|
2781
2785
|
end
|
2782
2786
|
|
@@ -2787,9 +2791,9 @@ module Meteor
|
|
2787
2791
|
arr_tmp = self.sort
|
2788
2792
|
end
|
2789
2793
|
hash_tmp = OrderHash.new
|
2790
|
-
arr_tmp.each
|
2794
|
+
arr_tmp.each do |item|
|
2791
2795
|
hash_tmp[item[0]] = item[1]
|
2792
|
-
|
2796
|
+
end
|
2793
2797
|
return hash_tmp
|
2794
2798
|
end
|
2795
2799
|
end
|
@@ -2883,7 +2887,7 @@ module Meteor
|
|
2883
2887
|
TYPE_L = 'type'
|
2884
2888
|
TYPE_U = 'TYPE'
|
2885
2889
|
|
2886
|
-
if RUBY_VERSION >=
|
2890
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
2887
2891
|
TABLE_FOR_ESCAPE_ = {
|
2888
2892
|
'&' => '&',
|
2889
2893
|
'"' => '"',
|
@@ -2964,10 +2968,10 @@ module Meteor
|
|
2964
2968
|
#
|
2965
2969
|
def initialize_1(ps)
|
2966
2970
|
@root.document = String.new(ps.document)
|
2967
|
-
@root.
|
2968
|
-
@root.hook = ps.
|
2969
|
-
@root.
|
2970
|
-
@root.
|
2971
|
+
@root.hook_document = String.new(ps.root_element.hook_document)
|
2972
|
+
@root.hook = ps.root_element.hook
|
2973
|
+
@root.mono_hook = ps.root_element.mono_hook
|
2974
|
+
@root.content_type = String.new(ps.content_type);
|
2971
2975
|
end
|
2972
2976
|
private :initialize_1
|
2973
2977
|
|
@@ -2978,7 +2982,7 @@ module Meteor
|
|
2978
2982
|
#
|
2979
2983
|
def parse(document)
|
2980
2984
|
@root.document = document
|
2981
|
-
|
2985
|
+
analyze_ml()
|
2982
2986
|
end
|
2983
2987
|
|
2984
2988
|
#
|
@@ -2987,36 +2991,36 @@ module Meteor
|
|
2987
2991
|
# @param [String] filePath ファイルパス
|
2988
2992
|
# @param [String] encoding エンコーディング
|
2989
2993
|
#
|
2990
|
-
def read(
|
2991
|
-
super(
|
2992
|
-
|
2994
|
+
def read(file_path,encoding)
|
2995
|
+
super(file_path,encoding)
|
2996
|
+
analyze_ml()
|
2993
2997
|
end
|
2994
2998
|
|
2995
2999
|
#
|
2996
3000
|
# ドキュメントをパースする
|
2997
3001
|
#
|
2998
|
-
def
|
3002
|
+
def analyze_ml()
|
2999
3003
|
#content-typeの取得
|
3000
|
-
|
3004
|
+
analyze_content_type()
|
3001
3005
|
#改行コードの取得
|
3002
|
-
|
3006
|
+
analyze_kaigyo_code()
|
3003
3007
|
|
3004
3008
|
@res = nil
|
3005
3009
|
end
|
3006
|
-
private :
|
3010
|
+
private :analyze_ml
|
3007
3011
|
|
3008
3012
|
# コンテントタイプを取得する
|
3009
3013
|
#
|
3010
3014
|
# @return [Streing]コンテントタイプ
|
3011
3015
|
#
|
3012
|
-
def
|
3013
|
-
@root.
|
3016
|
+
def content_type
|
3017
|
+
@root.content_type
|
3014
3018
|
end
|
3015
3019
|
|
3016
3020
|
#
|
3017
3021
|
# ドキュメントをパースし、コンテントタイプをセットする
|
3018
3022
|
#
|
3019
|
-
def
|
3023
|
+
def analyze_content_type
|
3020
3024
|
@elm_ = element(META_S,HTTP_EQUIV,CONTENT_TYPE)
|
3021
3025
|
|
3022
3026
|
if !@elm_ then
|
@@ -3024,59 +3028,59 @@ module Meteor
|
|
3024
3028
|
end
|
3025
3029
|
|
3026
3030
|
if @elm_ then
|
3027
|
-
@root.
|
3031
|
+
@root.content_type = @elm_.attribute(CONTENT)
|
3028
3032
|
else
|
3029
|
-
@root.
|
3033
|
+
@root.content_type = EMPTY
|
3030
3034
|
end
|
3031
3035
|
end
|
3032
|
-
private :
|
3036
|
+
private :analyze_content_type
|
3033
3037
|
|
3034
3038
|
#
|
3035
3039
|
# ドキュメントをパースし、改行コードをセットする
|
3036
3040
|
#
|
3037
|
-
def
|
3041
|
+
def analyze_kaigyo_code()
|
3038
3042
|
#改行コード取得
|
3039
3043
|
@pattern = Regexp.new(KAIGYO_CODE)
|
3040
3044
|
@res = @pattern.match(@root.document)
|
3041
3045
|
|
3042
3046
|
if @res then
|
3043
|
-
@root.
|
3047
|
+
@root.kaigyo_code = @res[1]
|
3044
3048
|
end
|
3045
3049
|
end
|
3046
|
-
private :
|
3050
|
+
private :analyze_kaigyo_code
|
3047
3051
|
|
3048
3052
|
#
|
3049
3053
|
# 要素名で検索し、要素を取得する
|
3050
3054
|
#
|
3051
|
-
# @param [String]
|
3055
|
+
# @param [String] elm_name 要素名
|
3052
3056
|
# @return [Meteor::Element] 要素
|
3053
3057
|
#
|
3054
|
-
def element_1(
|
3055
|
-
@
|
3058
|
+
def element_1(elm_name)
|
3059
|
+
@_elm_name = escape_regex(elm_name)
|
3056
3060
|
|
3057
3061
|
#空要素の場合(<->内容あり要素の場合)
|
3058
|
-
if
|
3062
|
+
if is_match(MATCH_TAG,elm_name) then
|
3059
3063
|
#空要素検索用パターン
|
3060
|
-
@pattern_cc = '' << TAG_OPEN << @
|
3064
|
+
@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_1_4_2
|
3061
3065
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3062
3066
|
@res = @pattern.match(@root.document)
|
3063
3067
|
if @res then
|
3064
|
-
|
3068
|
+
element_without_1(elm_name)
|
3065
3069
|
else
|
3066
3070
|
@elm_ = nil
|
3067
3071
|
end
|
3068
3072
|
else
|
3069
3073
|
#内容あり要素検索用パターン
|
3070
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
3071
|
-
#@pattern_cc << TAG_SEARCH_1_2 << @
|
3072
|
-
@pattern_cc = "<#{
|
3074
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_1_1 << elm_name
|
3075
|
+
#@pattern_cc << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
3076
|
+
@pattern_cc = "<#{elm_name}(\\s?[^<>]*)>(((?!(#{elm_name}[^<>]*>)).)*)<\\/#{elm_name}>"
|
3073
3077
|
|
3074
3078
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3075
3079
|
#内容あり要素検索
|
3076
3080
|
@res = @pattern.match(@root.document)
|
3077
3081
|
#内容あり要素の場合
|
3078
3082
|
if @res then
|
3079
|
-
|
3083
|
+
element_with_1(elm_name)
|
3080
3084
|
else
|
3081
3085
|
@elm_ = nil
|
3082
3086
|
end
|
@@ -3086,8 +3090,8 @@ module Meteor
|
|
3086
3090
|
end
|
3087
3091
|
private :element_1
|
3088
3092
|
|
3089
|
-
def
|
3090
|
-
@elm_ = Element.new(
|
3093
|
+
def element_without_1(elm_name)
|
3094
|
+
@elm_ = Element.new(elm_name)
|
3091
3095
|
#属性
|
3092
3096
|
@elm_.attributes = @res[1]
|
3093
3097
|
#空要素検索用パターン
|
@@ -3095,62 +3099,62 @@ module Meteor
|
|
3095
3099
|
|
3096
3100
|
@elm_.document = @res[0]
|
3097
3101
|
|
3098
|
-
@
|
3102
|
+
@elm_.parser = self
|
3099
3103
|
end
|
3100
|
-
private :
|
3104
|
+
private :element_without_1
|
3101
3105
|
|
3102
3106
|
#
|
3103
3107
|
# 要素名、属性(属性名="属性値")で検索し、要素を取得する
|
3104
3108
|
#
|
3105
|
-
# @param [String]
|
3106
|
-
# @param [String]
|
3107
|
-
# @param [String]
|
3109
|
+
# @param [String] elm_name 要素名
|
3110
|
+
# @param [String] attr_name 属性名
|
3111
|
+
# @param [String] attr_value 属性値
|
3108
3112
|
# @return [Meteor::Element] 要素
|
3109
3113
|
#
|
3110
|
-
def element_3(
|
3114
|
+
def element_3(elm_name,attr_name,attr_value)
|
3111
3115
|
|
3112
|
-
@
|
3113
|
-
@
|
3114
|
-
@
|
3116
|
+
@_elm_name = escape_regex(elm_name)
|
3117
|
+
@_attr_name = escape_regex(attr_name)
|
3118
|
+
@_attr_value = escape_regex(attr_value)
|
3115
3119
|
#空要素の場合(<->内容あり要素の場合)
|
3116
|
-
if
|
3120
|
+
if is_match(MATCH_TAG,elm_name) then
|
3117
3121
|
#空要素検索パターン
|
3118
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
3119
|
-
#@pattern_cc << @
|
3120
|
-
@pattern_cc = "<#{@
|
3122
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
3123
|
+
#@pattern_cc << @_attr_value << TAG_SEARCH_2_4_3
|
3124
|
+
@pattern_cc = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>"
|
3121
3125
|
|
3122
3126
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3123
3127
|
#空要素検索
|
3124
3128
|
@res = @pattern.match(@root.document)
|
3125
3129
|
if @res then
|
3126
|
-
|
3130
|
+
element_without_3(elm_name)
|
3127
3131
|
else
|
3128
3132
|
@elm_ = nil
|
3129
3133
|
end
|
3130
3134
|
else
|
3131
3135
|
#内容あり要素検索パターン
|
3132
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
3133
|
-
#@pattern_cc << @
|
3134
|
-
#@pattern_cc << TAG_SEARCH_1_2 << @
|
3135
|
-
@pattern_cc = "<#{@
|
3136
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
3137
|
+
#@pattern_cc << @_attr_value << TAG_SEARCH_2_2 << @_elm_name
|
3138
|
+
#@pattern_cc << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
3139
|
+
@pattern_cc = "<#{@_elm_name}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(#{@_elm_name}[^<>]*>)).)*)<\\/#{@_elm_name}>"
|
3136
3140
|
|
3137
3141
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3138
3142
|
#内容あり要素検索
|
3139
3143
|
@res = @pattern.match(@root.document)
|
3140
3144
|
|
3141
3145
|
if !@res then
|
3142
|
-
@res =
|
3146
|
+
@res = element_with_3_2(elm_name)
|
3143
3147
|
end
|
3144
3148
|
|
3145
3149
|
if @res then
|
3146
|
-
|
3150
|
+
element_with_3_1(elm_name)
|
3147
3151
|
else
|
3148
3152
|
@elm_ = nil
|
3149
3153
|
end
|
3150
3154
|
end
|
3151
3155
|
|
3152
3156
|
if @elm_ then
|
3153
|
-
@elm_.arguments.store(
|
3157
|
+
@elm_.arguments.store(attr_name, attr_value)
|
3154
3158
|
@elm_.arguments.recordable = true
|
3155
3159
|
end
|
3156
3160
|
|
@@ -3158,31 +3162,31 @@ module Meteor
|
|
3158
3162
|
end
|
3159
3163
|
private :element_3
|
3160
3164
|
|
3161
|
-
def
|
3162
|
-
|
3165
|
+
def element_without_3(elm_name)
|
3166
|
+
element_without_3_1(elm_name,TAG_SEARCH_NC_2_4_3)
|
3163
3167
|
end
|
3164
|
-
private :
|
3168
|
+
private :element_without_3
|
3165
3169
|
|
3166
3170
|
#
|
3167
3171
|
# 属性(属性名="属性値")で検索し、要素を取得する
|
3168
3172
|
#
|
3169
|
-
# @param [String]
|
3170
|
-
# @param [String]
|
3173
|
+
# @param [String] attr_name 属性名
|
3174
|
+
# @param [String] attr_value 属性値
|
3171
3175
|
# @return [Meteor::Element] 要素
|
3172
3176
|
#
|
3173
|
-
def element_2(
|
3174
|
-
@
|
3175
|
-
@
|
3177
|
+
def element_2(attr_name,attr_value)
|
3178
|
+
@_attr_name = escape_regex(attr_name)
|
3179
|
+
@_attr_value = escape_regex(attr_value)
|
3176
3180
|
|
3177
|
-
#@pattern_cc = '' << TAG_SEARCH_3_1 << @
|
3181
|
+
#@pattern_cc = '' << TAG_SEARCH_3_1 << @_attr_name << ATTR_EQ << @_attr_value
|
3178
3182
|
#@pattern_cc << TAG_SEARCH_2_4_4
|
3179
|
-
@pattern_cc = "<([^<>\"]*)\\s[^<>]*#{@
|
3183
|
+
@pattern_cc = "<([^<>\"]*)\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*>"
|
3180
3184
|
|
3181
3185
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3182
3186
|
@res = @pattern.match(@root.document)
|
3183
3187
|
|
3184
3188
|
if @res then
|
3185
|
-
@elm_ = element_3(@res[1],
|
3189
|
+
@elm_ = element_3(@res[1],attr_name,attr_value)
|
3186
3190
|
else
|
3187
3191
|
@elm_ = nil
|
3188
3192
|
end
|
@@ -3194,68 +3198,68 @@ module Meteor
|
|
3194
3198
|
#
|
3195
3199
|
# 要素名と属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
3196
3200
|
#
|
3197
|
-
# @param [String]
|
3198
|
-
# @param
|
3199
|
-
# @param
|
3200
|
-
# @param
|
3201
|
-
# @param
|
3201
|
+
# @param [String] elm_name 要素名
|
3202
|
+
# @param attr_name1 属性名1
|
3203
|
+
# @param attr_value1 属性値1
|
3204
|
+
# @param attr_name2 属性名2
|
3205
|
+
# @param attr_value2 属性値2
|
3202
3206
|
# @return [Meteor::Element] 要素
|
3203
3207
|
#
|
3204
|
-
def element_5(
|
3208
|
+
def element_5(elm_name,attr_name1,attr_value1,attr_name2,attr_value2)
|
3205
3209
|
|
3206
|
-
@
|
3207
|
-
@
|
3208
|
-
@
|
3209
|
-
@
|
3210
|
-
@
|
3210
|
+
@_elm_name = escape_regex(elm_name)
|
3211
|
+
@_attr_name1 = escape_regex(attr_name1)
|
3212
|
+
@_attr_value1 = escape_regex(attr_value1)
|
3213
|
+
@_attr_name2 = escape_regex(attr_name2)
|
3214
|
+
@_attr_value2 = escape_regex(attr_value2)
|
3211
3215
|
|
3212
3216
|
#空要素の場合(<->内容あり要素の場合)
|
3213
|
-
if
|
3217
|
+
if is_match(MATCH_TAG,elm_name) then
|
3214
3218
|
#空要素検索パターン
|
3215
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
3216
|
-
#@pattern_cc << @
|
3217
|
-
#@pattern_cc << @
|
3218
|
-
#@pattern_cc << @
|
3219
|
-
#@pattern_cc << @
|
3220
|
-
@pattern_cc = "<#{@
|
3219
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
3220
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
3221
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
3222
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
3223
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_4_3_2
|
3224
|
+
@pattern_cc = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>"
|
3221
3225
|
|
3222
3226
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3223
3227
|
#空要素検索
|
3224
3228
|
@res = @pattern.match(@root.document)
|
3225
3229
|
|
3226
3230
|
if @res then
|
3227
|
-
|
3231
|
+
element_without_5(elm_name)
|
3228
3232
|
else
|
3229
3233
|
@elm_ = nil
|
3230
3234
|
end
|
3231
3235
|
else
|
3232
3236
|
#内容あり要素検索パターン
|
3233
|
-
#@pattern_cc = '' << TAG_OPEN << @
|
3234
|
-
#@pattern_cc << @
|
3235
|
-
#@pattern_cc << @
|
3236
|
-
#@pattern_cc << @
|
3237
|
-
#@pattern_cc << @
|
3238
|
-
#@pattern_cc << TAG_SEARCH_1_2 << @
|
3239
|
-
@pattern_cc = "<#{@
|
3237
|
+
#@pattern_cc = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1_2 << @_attr_name1 << ATTR_EQ
|
3238
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ
|
3239
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ
|
3240
|
+
#@pattern_cc << @_attr_value2 << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ
|
3241
|
+
#@pattern_cc << @_attr_value1 << TAG_SEARCH_2_2_2 << @_elm_name
|
3242
|
+
#@pattern_cc << TAG_SEARCH_1_2 << @_elm_name << TAG_CLOSE
|
3243
|
+
@pattern_cc = "<#{@_elm_name}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_elm_name}[^<>]*>)).)*)<\\/#{@_elm_name}>"
|
3240
3244
|
|
3241
3245
|
@pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
|
3242
3246
|
#内容あり要素検索
|
3243
3247
|
@res = @pattern.match(@root.document)
|
3244
3248
|
|
3245
3249
|
if !@res then
|
3246
|
-
@res =
|
3250
|
+
@res = element_with_5_2(elm_name)
|
3247
3251
|
end
|
3248
3252
|
|
3249
3253
|
if @res then
|
3250
|
-
|
3254
|
+
element_with_5_1(elm_name)
|
3251
3255
|
else
|
3252
3256
|
@elm_ = nil
|
3253
3257
|
end
|
3254
3258
|
end
|
3255
3259
|
|
3256
3260
|
if @elm_ then
|
3257
|
-
@elm_.arguments.store(
|
3258
|
-
@elm_.arguments.store(
|
3261
|
+
@elm_.arguments.store(attr_name1, attr_value1)
|
3262
|
+
@elm_.arguments.store(attr_name2, attr_value2)
|
3259
3263
|
@elm_.arguments.recordable = true
|
3260
3264
|
end
|
3261
3265
|
|
@@ -3263,39 +3267,39 @@ module Meteor
|
|
3263
3267
|
end
|
3264
3268
|
private :element_5
|
3265
3269
|
|
3266
|
-
def
|
3267
|
-
|
3270
|
+
def element_without_5(elm_name)
|
3271
|
+
element_without_5_1(elm_name,TAG_SEARCH_NC_2_4_3_2)
|
3268
3272
|
end
|
3269
|
-
private :
|
3273
|
+
private :element_without_5
|
3270
3274
|
|
3271
3275
|
#
|
3272
3276
|
# 属性1・属性2(属性名="属性値")で検索し、要素を取得する
|
3273
3277
|
#
|
3274
|
-
# @param [String]
|
3275
|
-
# @param [String]
|
3276
|
-
# @param [String]
|
3277
|
-
# @param [String]
|
3278
|
+
# @param [String] attr_name1 属性名1
|
3279
|
+
# @param [String] attr_value1 属性値1
|
3280
|
+
# @param [String] attr_name2 属性名2
|
3281
|
+
# @param [String] attr_value2 属性値2
|
3278
3282
|
# @return [Meteor::Element] 要素
|
3279
3283
|
#
|
3280
|
-
def element_4(
|
3281
|
-
@
|
3282
|
-
@
|
3283
|
-
@
|
3284
|
-
@
|
3285
|
-
|
3286
|
-
#@pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @
|
3287
|
-
#@pattern_cc << TAG_SEARCH_2_6 << @
|
3288
|
-
#@pattern_cc << TAG_SEARCH_2_7 << @
|
3289
|
-
#@pattern_cc << TAG_SEARCH_2_6 << @
|
3284
|
+
def element_4(attr_name1,attr_value1,attr_name2,attr_value2)
|
3285
|
+
@_attr_name1 = escape_regex(attr_name1)
|
3286
|
+
@_attr_value1 = escape_regex(attr_value1)
|
3287
|
+
@_attr_name2 = escape_regex(attr_name2)
|
3288
|
+
@_attr_value2 = escape_regex(attr_value2)
|
3289
|
+
|
3290
|
+
#@pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @_attr_name1 << ATTR_EQ << @_attr_value1
|
3291
|
+
#@pattern_cc << TAG_SEARCH_2_6 << @_attr_name2 << ATTR_EQ << @_attr_value2
|
3292
|
+
#@pattern_cc << TAG_SEARCH_2_7 << @_attr_name2 << ATTR_EQ << @_attr_value2
|
3293
|
+
#@pattern_cc << TAG_SEARCH_2_6 << @_attr_name1 << ATTR_EQ << @_attr_value1
|
3290
3294
|
#@pattern_cc << TAG_SEARCH_2_4_3_2
|
3291
|
-
@
|
3295
|
+
@pattern_cc = "<([^<>\"]*)\\s([^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>"
|
3292
3296
|
|
3293
3297
|
@pattern = PatternCache.get(@pattern_cc)
|
3294
3298
|
|
3295
3299
|
@res = @pattern.match(@root.document)
|
3296
3300
|
|
3297
3301
|
if @res then
|
3298
|
-
@elm_ = element_5(@res[1],
|
3302
|
+
@elm_ = element_5(@res[1],attr_name1,attr_value1,attr_name2,attr_value2)
|
3299
3303
|
else
|
3300
3304
|
@elm_ = nil
|
3301
3305
|
end
|
@@ -3304,32 +3308,32 @@ module Meteor
|
|
3304
3308
|
end
|
3305
3309
|
private :element_4
|
3306
3310
|
|
3307
|
-
def
|
3308
|
-
if
|
3309
|
-
|
3310
|
-
#
|
3311
|
-
elsif
|
3312
|
-
|
3313
|
-
#
|
3314
|
-
elsif
|
3315
|
-
|
3316
|
-
#
|
3317
|
-
elsif
|
3318
|
-
|
3319
|
-
#
|
3320
|
-
elsif
|
3321
|
-
|
3322
|
-
#
|
3311
|
+
def edit_attributes_(elm,attr_name,attr_value)
|
3312
|
+
if is_match(SELECTED, attr_name) && is_match(OPTION,elm.name) then
|
3313
|
+
edit_attributes_5(elm,attr_name,attr_value,@@pattern_selected_m,@@pattern_selected_r)
|
3314
|
+
#edit_attributes_5(elm,attr_name,attr_value,SELECTED_M,@@pattern_selected_r)
|
3315
|
+
elsif is_match(MULTIPLE, attr_name) && is_match(SELECT,elm.name)
|
3316
|
+
edit_attributes_5(elm,attr_name,attr_value,@@pattern_multiple_m,@@pattern_multiple_r)
|
3317
|
+
#edit_attributes_5(elm,attr_name,attr_value,MULTIPLE_M,@@pattern_multiple_r)
|
3318
|
+
elsif is_match(DISABLED, attr_name) && is_match(DISABLE_ELEMENT, elm.name) then
|
3319
|
+
edit_attributes_5(elm,attr_name,attr_value,@@pattern_disabled_m,@@pattern_disabled_r)
|
3320
|
+
#edit_attributes_5(elm,attr_name,attr_value,DISABLED_M,@@pattern_disabled_r)
|
3321
|
+
elsif is_match(CHECKED, attr_name) && is_match(INPUT,elm.name) && is_match(RADIO, get_type(elm)) then
|
3322
|
+
edit_attributes_5(elm,attr_name,attr_value,@@pattern_checked_m,@@pattern_checked_r)
|
3323
|
+
#edit_attributes_5(elm,attr_name,attr_value,CHECKED_M,@@pattern_checked_r)
|
3324
|
+
elsif is_match(READONLY, attr_name) && (is_match(TEXTAREA,elm.name) || (is_match(INPUT,elm.name) && is_match(READONLY_TYPE, get_type(elm)))) then
|
3325
|
+
edit_attributes_5(elm,attr_name,attr_value,@@pattern_readonly_m,@@pattern_readonly_r)
|
3326
|
+
#edit_attributes_5(elm,attr_name,attr_value,READONLY_M,@@pattern_readonly_r)
|
3323
3327
|
else
|
3324
|
-
super(elm,
|
3328
|
+
super(elm,attr_name,attr_value)
|
3325
3329
|
end
|
3326
3330
|
end
|
3327
|
-
private :
|
3331
|
+
private :edit_attributes_
|
3328
3332
|
|
3329
|
-
def
|
3330
|
-
#
|
3333
|
+
def edit_attributes_5(elm,attr_name,attr_value,match_p,replace)
|
3334
|
+
#attr_value = escape(attr_value)
|
3331
3335
|
|
3332
|
-
if
|
3336
|
+
if is_match(TRUE, attr_value) then
|
3333
3337
|