meteor 0.9.8.3 → 0.9.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,66 +1,56 @@
1
1
  #!bin ruby
2
2
  # -* coding: UTF-8 -*-
3
3
 
4
- require 'rubygems'
4
+ #require 'rubygems'
5
5
  require 'meteor'
6
6
 
7
- #pf = Meteor::ParserFactory.new
8
- #pf.parser(Meteor::Parser::XML,'sample.xml', 'UTF-8')
9
- #pf.bind(Meteor::Parser::XML,'sample.xml')
10
-
11
- #root = pf.element('sample')
12
-
13
- Meteor::ElementFactory.bind(Meteor::XML,'sample.xml', 'UTF-8')
14
- root = Meteor::ElementFactory.element('sample')
7
+ Meteor::ElementFactory.link(Meteor::XML,'ml/sample.xml', 'UTF-8')
8
+ root = Meteor::ElementFactory.element('/ml/sample')
15
9
 
16
10
  start_time = Time.new.to_f
17
11
 
18
- #elm_ = root.element('test1')
12
+ #elm_ = root.element('kobe')
19
13
  #puts elm_.name
20
14
  #puts elm_.attributes
21
15
  #puts elm_.mixed_content
16
+ #puts elm_.text
22
17
 
23
18
  #elm_ = root.element('test')
24
19
  #puts elm_.name
25
20
  #puts elm_.attributes
26
21
  #puts elm_.mixed_content
27
22
 
28
- elm1 = root.element('test','manbo'=>'manbo')
29
- #elm1 = root.element("manbo"=>"manbo")
30
- #elm2 = root.element("id"=>"aa","id2"=>"bb")
31
- #elm2 = root.element("id"=>"aa")
32
- #elm3 = root.element("potato","id"=>"aa")
33
- #elm4 = root.element("potato","id"=>"aa","id2"=>"bb")
34
- #elm4 = root.element("potato","id2"=>"bb")
23
+ elm1 = root.element('test', manbo: 'manbo') #elm1 = root.element(manbo: "manbo")
24
+ #elm2 = root.element(id: "aa", id2: "bb") #elm2 = root.element(id: "aa")
25
+ #elm3 = root.element("potato", id: "aa")
26
+ #elm4 = root.element("potato", id: "aa", id2: "bb") #elm4 = root.element("potato", id2: "bb")
27
+
35
28
  elm7 = root.element("kobe")
36
- #elm7 = root.element("momo"=>"mono")
37
- #elm8 = root.element("manbo"=>"mango")
38
- #elm8 = root.element("momo"=>"momo")
29
+ #elm7 = root.element(momo: "mono")
30
+ #elm8 = root.element(manbo: "mango")
31
+ #elm8 = root.element(momo: "momo")
39
32
 
40
- #elm9 = root.element("hamachi","id"=>"aa",'id2'=>'bb')
33
+ #elm9 = root.element("hamachi",id: "aa",id2: 'bb')
41
34
  #elm_c1 = root.cxtag("cs")
42
35
 
43
- #elm8.attr("manbo"=>"mangoo")
44
-
45
36
  #puts elm8.name
46
37
  #puts elm8.attributes
47
38
  #puts elm8.mixed_content
48
39
 
49
- #elm1.attr("id2"=>"cc")
50
- #elm1["id2"]="cc"
40
+ #elm1.attr(id2: "cc")
41
+ #elm1["id2"] = "cc"
51
42
 
52
- #elm8.attr("manbo"=>"mangoo")
53
- ##elm9.content("\\1")
54
- #elm9.content = "\\1"
43
+ #elm8['mango'] = "mangoo" #elm8.attr(manbo: "mangoo")
44
+ #elm9.content = "\\1" #elm9.content("\\1")
55
45
 
56
- #elm2.attr('id3'=>'cc')
57
- #elm3.attr('id3'=>'cc')
58
- #elm3['id3'] = 'cc'
59
- #elm4.attr('id3'=>'cc')
60
- #elm9.attr('id3'=>'cc')
46
+ #elm2.attr(id3: 'cc')
61
47
 
62
- #co_ps = elm1.element()
63
- #map = co_ps.attr_map
48
+ #elm3['id3'] = 'cc' #elm3.attr(id3: 'cc')
49
+ #elm3['id3'] = 'cc' #elm4.attr(id3: 'cc')
50
+ #elm9['id3'] = 'cc' #elm9.attr(id3: 'cc')
51
+
52
+ #co_elm = elm1.element()
53
+ #map = co_elm.attr_map
64
54
  #map.names.each { |item|
65
55
  # puts item
66
56
  # puts map.fetch(item)
@@ -73,7 +63,7 @@ elm5_ = elm_.element('tech')
73
63
  elm5 = elm5_.clone
74
64
  elm5['mono'] = i.to_s
75
65
  elm5.content = i.to_s
76
- elm_.flush
66
+ elm_.flash
77
67
  end
78
68
 
79
69
  #am3 = elm3.attr_map
@@ -85,29 +75,38 @@ end
85
75
  elm_ = root.element(elm7)
86
76
 
87
77
  10.times { |i|
88
- elm_["momo"]= i.to_s
78
+ elm_["momo"]= i
89
79
  elm_["eco"] = "えま"
90
- elm_.content = i.to_s
91
- #elm_["content"] = i.to_s
92
- elm_.flush
80
+ elm_.content = i #elm_["content"] = i.to_s
81
+ elm_.flash
93
82
  }
94
83
 
95
- #co_ps = root.element(elm_c1)
84
+ #co_elm = root.element(elm_c1)
96
85
  #
97
86
  #10.times { |i|
98
- # #co_ps.content(i.to_s)
99
- # co_ps[":content"]=i.to_s
100
- # co_ps.flush
87
+ # co_elm.content = i #co_elm.content(i)
88
+ # co_elm.flash
101
89
  #}
102
90
 
103
- root.flush
91
+ #elm3['id3'] = 'dd' #elm3.attr(id3: 'dd')
104
92
 
105
- #elm3.attr('id3'=>'dd')
93
+ root.flash
106
94
 
107
95
  end_time = Time.new.to_f
108
96
 
109
97
  puts root.document
110
98
 
99
+ #elms = root.elements("potato2")
100
+ ##elms = root.elements("kobe")
101
+ #elms = root.elements("potato")
102
+
103
+ elms = root.elements("test") #elms = root.css('test')
104
+ elms.each{|elm|
105
+ puts elm.document
106
+ puts elm.attributes
107
+ puts elm.mixed_content
108
+ }
109
+
111
110
  puts '' + (end_time - start_time).to_s + ' sec'
112
111
 
113
112
  #start_time = Time.new.to_f
@@ -29,7 +29,7 @@
29
29
  <mink>komaneti</mink>
30
30
 
31
31
  <potato id="aa" lc="/cc">
32
- <potato id="/bb"><test></test></potato>
32
+ <potato id="/bb"></potato>
33
33
  </potato>
34
34
 
35
35
  <potato id="aa" id2="bb" lc="/cc">
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  # -* coding: UTF-8 -*-
2
2
  # Meteor - A lightweight (X)HTML(5) & XML parser
3
3
  #
4
- # Copyright (C) 2008-2014 Yasumasa Ashida.
4
+ # Copyright (C) 2008-2016 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,12 +18,12 @@
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.8.3
21
+ # @version 0.9.8.4
22
22
  #
23
23
 
24
24
  module Meteor
25
25
 
26
- VERSION = '0.9.8.3'.freeze
26
+ VERSION = '0.9.8.4'.freeze
27
27
 
28
28
  #require 'fileutils'
29
29
 
@@ -37,10 +37,11 @@ module Meteor
37
37
  SEVEN = 7
38
38
 
39
39
  HTML = ZERO
40
- XHTML = ONE
41
- HTML5 = TWO
42
- XHTML5 = THREE
43
- XML = FOUR
40
+ HTML5 = ONE
41
+ XHTML5 = TWO
42
+ HTML4 = THREE
43
+ XHTML4 = FOUR
44
+ XML = FIVE
44
45
 
45
46
  #
46
47
  # Element Class (要素クラス)
@@ -241,7 +242,7 @@ module Meteor
241
242
  if @document_sync
242
243
  @document_sync = false
243
244
  case @parser.doc_type
244
- when Parser::HTML, Parser::HTML5
245
+ when Parser::HTML, Parser::HTML5, Parser::HTML4
245
246
  if @cx
246
247
  #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4
247
248
  @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->"
@@ -254,7 +255,7 @@ module Meteor
254
255
  #@document = "<#{@name}#{@attributes}>"
255
256
  end
256
257
  end
257
- when Parser::XHTML, Parser::XHTML5, Parser::XML
258
+ when Parser::XHTML4, Parser::XHTML5, Parser::XML
258
259
  if @cx
259
260
  #@pattern_cc = '' << SET_CX_1 << elm.tag << SPACE << elm.attributes << SET_CX_2 << elm.mixed_content << SET_CX_3 << elm.tag << SET_CX_4
260
261
  @document = "<!-- @#{@tag} #{@attributes} -->#{@mixed_content}<!-- /@#{@tag} -->"
@@ -496,6 +497,8 @@ module Meteor
496
497
  @parser.content(self, *args)
497
498
  end
498
499
 
500
+ alias :text :content
501
+
499
502
  #
500
503
  # set content of element (要素の内容をセットする)
501
504
  # @param [String] value content (要素の内容)
@@ -505,6 +508,8 @@ module Meteor
505
508
  @parser.content(self, value)
506
509
  end
507
510
 
511
+ alias :text= :content=
512
+
508
513
  #
509
514
  # set attribute (属性をセットする)
510
515
  # @param [String,Symbol] name attribute name (属性の名前)
@@ -512,7 +517,11 @@ module Meteor
512
517
  # @return [Meteor::Element] element (要素)
513
518
  #
514
519
  def []=(name, value)
515
- @parser.attr(self, name, value)
520
+ if value != nil
521
+ @parser.attr(self, name, value)
522
+ else
523
+ @parser.remove_attr(self, name)
524
+ end
516
525
  end
517
526
 
518
527
  #
@@ -543,10 +552,12 @@ module Meteor
543
552
  #
544
553
  # reflect (反映する)
545
554
  #
546
- def flush
547
- @parser.flush
555
+ def flash
556
+ @parser.flash
548
557
  end
549
558
 
559
+ alias :flush :flash
560
+
550
561
  #
551
562
  # @overload execute(hook)
552
563
  # run action of Hooker (Hookerクラスの処理を実行する)
@@ -766,10 +777,11 @@ module Meteor
766
777
  #
767
778
  class Parser
768
779
  HTML = ZERO
769
- XHTML = ONE
770
- HTML5 = TWO
771
- XHTML5 = THREE
772
- XML = FOUR
780
+ HTML5 = ONE
781
+ XHTML5 = TWO
782
+ HTML4 = THREE
783
+ XHTML4 = FOUR
784
+ XML = FIVE
773
785
  end
774
786
 
775
787
  #
@@ -917,41 +929,41 @@ module Meteor
917
929
  end
918
930
 
919
931
  #
920
- #@overload bind(relative_path,enc)
932
+ #@overload link(relative_path,enc)
921
933
  # generate parser (パーサを作成する)
922
934
  # @param [String] relative_path relative file path (相対ファイルパス)
923
935
  # @param [String] enc character encoding (文字エンコーディング)
924
936
  # @return [Meteor::Parser] parser (パーサ)
925
- #@overload bind(relative_path)
937
+ #@overload link(relative_path)
926
938
  # generate parser (パーサを作成する)
927
939
  # @param [String] relative_path relative file path (相対ファイルパス)
928
940
  # @return [Meteor::Parser] parser (パーサ)
929
- #@overload bind(type,relative_path,enc)
941
+ #@overload link(type,relative_path,enc)
930
942
  # generate parser (パーサを作成する)
931
943
  # @param [Fixnum,Symbol] type type of parser (パーサ・タイプ)
932
944
  # @param [String] relative_path relative file path (相対ファイルパス)
933
945
  # @param [String] enc character encoding (文字エンコーディング)
934
946
  # @return [Meteor::Parser] parser (パーサ)
935
- #@overload bind(type,relative_path)
947
+ #@overload link(type,relative_path)
936
948
  # generate parser (パーサを作成する)
937
949
  # @param [Fixnum,Symbol] type type of parser (パーサ・タイプ)
938
950
  # @param [String] relative_path relative file path (相対ファイルパス)
939
951
  # @return [Meteor::Parser] parser (パーサ)
940
952
  #
941
- def bind(*args)
953
+ def link(*args)
942
954
  case args.length
943
955
  when 1
944
- bind_1(args[0])
956
+ link_1(args[0])
945
957
  when 2
946
958
  if args[0].kind_of?(Fixnum) || args[0].kind_of?(Symbol)
947
- bind_2_n(args[0], args[1])
959
+ link_2_n(args[0], args[1])
948
960
  elsif args[0].kind_of?(String)
949
- bind_2_s(args[0], args[1])
961
+ link_2_s(args[0], args[1])
950
962
  else
951
963
  raise ArgumentError
952
964
  end
953
965
  when 3
954
- bind_3(args[0], args[1], args[2])
966
+ link_3(args[0], args[1], args[2])
955
967
  else
956
968
  raise ArgumentError
957
969
  end
@@ -971,10 +983,10 @@ module Meteor
971
983
  if CURRENT_DIR.eql?(paths[0])
972
984
  paths.delete_at 0
973
985
  paths[paths.length - 1] = File.basename(paths[paths.length - 1], ABST_EXT_NAME)
974
- return paths.join(SLASH)
986
+ return '' << SLASH << paths.join(SLASH)
975
987
  else
976
988
  paths[paths.length - 1] = File.basename(paths[paths.length - 1], ABST_EXT_NAME)
977
- return paths.join(SLASH)
989
+ return '' << SLASH << paths.join(SLASH)
978
990
  end
979
991
  end
980
992
  end
@@ -988,20 +1000,20 @@ module Meteor
988
1000
  # @param [String] enc character encoding (文字エンコーディング)
989
1001
  # @return [Meteor::Parser] parser(パーサ)
990
1002
  #
991
- def bind_3(type, relative_path, enc)
1003
+ def link_3(type, relative_path, enc)
992
1004
 
993
1005
  relative_url = path_to_url(relative_path)
994
1006
 
995
1007
  case type
996
- when Parser::HTML, :html
997
- html = Meteor::Ml::Html::ParserImpl.new
1008
+ when Parser::HTML4, :html4
1009
+ html4 = Meteor::Ml::Html4::ParserImpl.new
998
1010
  html.read(File.expand_path(relative_path, @root), enc)
999
- @cache[relative_url] = html
1000
- when Parser::XHTML
1001
- xhtml = Meteor::Ml::Xhtml::ParserImpl.new
1002
- xhtml.read(File.expand_path(relative_path, @root), enc)
1003
- @cache[relative_url] = xhtml
1004
- when Parser::HTML5, :html5
1011
+ @cache[relative_url] = html4
1012
+ when Parser::XHTML4, :xhtml4
1013
+ xhtml4 = Meteor::Ml::Xhtml4::ParserImpl.new
1014
+ xhtml4.read(File.expand_path(relative_path, @root), enc)
1015
+ @cache[relative_url] = xhtml4
1016
+ when Parser::HTML, :html, Parser::HTML5, :html5
1005
1017
  html5 = Meteor::Ml::Html5::ParserImpl.new
1006
1018
  html5.read(File.expand_path(relative_path, @root), enc)
1007
1019
  @cache[relative_url] = html5
@@ -1016,7 +1028,7 @@ module Meteor
1016
1028
  end
1017
1029
  end
1018
1030
 
1019
- private :bind_3
1031
+ private :link_3
1020
1032
 
1021
1033
  #
1022
1034
  # generate parser (パーサを作成する)
@@ -1024,16 +1036,16 @@ module Meteor
1024
1036
  # @param [String] relative_path relative file path (相対ファイルパス)
1025
1037
  # @return [Meteor::Parser] parser (パーサ)
1026
1038
  #
1027
- def bind_2_n(type, relative_path)
1039
+ def link_2_n(type, relative_path)
1028
1040
 
1029
1041
  relative_url = path_to_url(relative_path)
1030
1042
 
1031
1043
  case type
1032
- when Parser::HTML, :html
1033
- ps = Meteor::Ml::Html::ParserImpl.new
1044
+ when Parser::HTML4, :html4
1045
+ ps = Meteor::Ml::Html4::ParserImpl.new
1034
1046
  when Parser::XHTML, :xhtml
1035
- ps = Meteor::Ml::Xhtml::ParserImpl.new
1036
- when Parser::HTML5, :html5
1047
+ ps = Meteor::Ml::Xhtml4::ParserImpl.new
1048
+ when Parser::HTML, :html, Parser::HTML5, :html5
1037
1049
  ps = Meteor::Ml::Html5::ParserImpl.new
1038
1050
  when Parser::XHTML5, :xhtml5
1039
1051
  ps = Meteor::Ml::Xhtml5::ParserImpl.new
@@ -1046,7 +1058,7 @@ module Meteor
1046
1058
 
1047
1059
  end
1048
1060
 
1049
- private :bind_2_n
1061
+ private :link_2_n
1050
1062
 
1051
1063
  #
1052
1064
  # generate parser (パーサを作成する)
@@ -1054,16 +1066,16 @@ module Meteor
1054
1066
  # @param [String] enc character encoding (文字エンコーディング)
1055
1067
  # @return [Meteor::Parser] parser (パーサ)
1056
1068
  #
1057
- def bind_2_s(relative_path,enc)
1069
+ def link_2_s(relative_path,enc)
1058
1070
 
1059
1071
  relative_url = path_to_url(relative_path)
1060
1072
 
1061
1073
  case @type
1062
- when Parser::HTML, :html
1063
- ps = Meteor::Ml::Html::ParserImpl.new
1074
+ when Parser::HTML4, :html4
1075
+ ps = Meteor::Ml::Html4::ParserImpl.new
1064
1076
  when Parser::XHTML, :xhtml
1065
- ps = Meteor::Ml::Xhtml::ParserImpl.new
1066
- when Parser::HTML5, :html5
1077
+ ps = Meteor::Ml::Xhtml4::ParserImpl.new
1078
+ when Parser::HTML, :html, Parser::HTML5, :html5
1067
1079
  ps = Meteor::Ml::Html5::ParserImpl.new
1068
1080
  when Parser::XHTML5, :xhtml5
1069
1081
  ps = Meteor::Ml::Xhtml5::ParserImpl.new
@@ -1076,23 +1088,23 @@ module Meteor
1076
1088
 
1077
1089
  end
1078
1090
 
1079
- private :bind_2_s
1091
+ private :link_2_s
1080
1092
 
1081
1093
  #
1082
1094
  # generate parser (パーサを作成する)
1083
1095
  # @param [String] relative_path relative file path (相対ファイルパス)
1084
1096
  # @return [Meteor::Parser] parser (パーサ)
1085
1097
  #
1086
- def bind_1(relative_path)
1098
+ def link_1(relative_path)
1087
1099
 
1088
1100
  relative_url = path_to_url(relative_path)
1089
1101
 
1090
1102
  case @type
1091
- when Parser::HTML, :html
1092
- ps = Meteor::Ml::Html::ParserImpl.new
1103
+ when Parser::HTML4, :html4
1104
+ ps = Meteor::Ml::Html4::ParserImpl.new
1093
1105
  when Parser::XHTML, :xhtml
1094
- ps = Meteor::Ml::Xhtml::ParserImpl.new
1095
- when Parser::HTML5, :html5
1106
+ ps = Meteor::Ml::Xhtml4::ParserImpl.new
1107
+ when Parser::HTML, :html, Parser::HTML5, :html5
1096
1108
  ps = Meteor::Ml::Html5::ParserImpl.new
1097
1109
  when Parser::XHTML5, :xhtml5
1098
1110
  ps = Meteor::Ml::Xhtml5::ParserImpl.new
@@ -1107,7 +1119,7 @@ module Meteor
1107
1119
 
1108
1120
  end
1109
1121
 
1110
- private :bind_1
1122
+ private :link_1
1111
1123
 
1112
1124
  #
1113
1125
  #@overload parser(key)
@@ -1132,7 +1144,7 @@ module Meteor
1132
1144
  when 1
1133
1145
  parser_1(args[0])
1134
1146
  when 2,3
1135
- bind(args)
1147
+ link(args)
1136
1148
  end
1137
1149
  #parser_1(key)
1138
1150
  end
@@ -1145,11 +1157,11 @@ module Meteor
1145
1157
  def parser_1(key)
1146
1158
  @pif = @cache[key.to_s]
1147
1159
  case @pif.doc_type
1148
- when Meteor::Parser::HTML
1149
- Meteor::Ml::Html::ParserImpl.new(@pif)
1150
- when Meteor::Parser::XHTML
1151
- Meteor::Ml::Xhtml::ParserImpl.new(@pif)
1152
- when Meteor::Parser::HTML5
1160
+ when Meteor::Parser::HTML4
1161
+ Meteor::Ml::Html4::ParserImpl.new(@pif)
1162
+ when Meteor::Parser::XHTML4
1163
+ Meteor::Ml::Xhtml4::ParserImpl.new(@pif)
1164
+ when Meteor::Parser::HTML, Meteor::Parser::HTML5
1153
1165
  Meteor::Ml::Html5::ParserImpl.new(@pif)
1154
1166
  when Meteor::Parser::XHTML5
1155
1167
  Meteor::Ml::Xhtml5::ParserImpl.new(@pif)
@@ -1170,24 +1182,24 @@ module Meteor
1170
1182
  end
1171
1183
 
1172
1184
  #
1173
- # @overload bind_str(type, relative_url, doc)
1185
+ # @overload link_str(type, relative_url, doc)
1174
1186
  # generate parser (パーサを作成する)
1175
1187
  # @param [Fixnum] type type of parser (パーサ・タイプ)
1176
1188
  # @param [String] relative_url relative URL (相対URL)
1177
1189
  # @param [String] doc document (ドキュメント)
1178
1190
  # @return [Meteor::Parser] parser (パーサ)
1179
- # @overload bind_str(relative_url, doc)
1191
+ # @overload link_str(relative_url, doc)
1180
1192
  # generate parser (パーサを作成する)
1181
1193
  # @param [String] relative_url relative URL (相対URL)
1182
1194
  # @param [String] doc document (ドキュメント)
1183
1195
  # @return [Meteor::Parser] parser (パーサ)
1184
1196
  #
1185
- def bind_str(*args)
1197
+ def link_str(*args)
1186
1198
  case args.length
1187
1199
  when 2
1188
- bind_str_2(args[0],args[1])
1200
+ link_str_2(args[0],args[1])
1189
1201
  when 3
1190
- bind_str_3(args[0],args[1],args[2])
1202
+ link_str_3(args[0],args[1],args[2])
1191
1203
  else
1192
1204
  raise ArgumentError
1193
1205
  end
@@ -1200,13 +1212,13 @@ module Meteor
1200
1212
  # @param [String] doc document (ドキュメント)
1201
1213
  # @return [Meteor::Parser] parser (パーサ)
1202
1214
  #
1203
- def bind_str_3(type, relative_url, doc)
1215
+ def link_str_3(type, relative_url, doc)
1204
1216
  case type
1205
- when Parser::HTML, :html
1206
- ps = Meteor::Ml::Html::ParserImpl.new
1217
+ when Parser::HTML4, :html
1218
+ ps = Meteor::Ml::Html4::ParserImpl.new
1207
1219
  when Parser::XHTML, :xhtml
1208
- ps = Meteor::Ml::Xhtml::ParserImpl.new
1209
- when Parser::HTML5, :html5
1220
+ ps = Meteor::Ml::Xhtml4::ParserImpl.new
1221
+ when Parser::HTML, :html, Parser::HTML5, :html5
1210
1222
  ps = Meteor::Ml::Html5::ParserImpl.new
1211
1223
  when Parser::XHTML5, :xhtml5
1212
1224
  ps = Meteor::Ml::Xhtml5::ParserImpl.new
@@ -1219,7 +1231,7 @@ module Meteor
1219
1231
  @cache[relative_url] = ps
1220
1232
  end
1221
1233
 
1222
- private :bind_str_3
1234
+ private :link_str_3
1223
1235
 
1224
1236
  #
1225
1237
  # generate parser (パーサを作成する)
@@ -1227,13 +1239,13 @@ module Meteor
1227
1239
  # @param [String] doc document (ドキュメント)
1228
1240
  # @return [Meteor::Parser] parser (パーサ)
1229
1241
  #
1230
- def bind_str_2(relative_url, doc)
1242
+ def link_str_2(relative_url, doc)
1231
1243
  case @type
1232
- when Parser::HTML, :html
1233
- ps = Meteor::Ml::Html::ParserImpl.new
1244
+ when Parser::HTML4, :html4
1245
+ ps = Meteor::Ml::Html4::ParserImpl.new
1234
1246
  when Parser::XHTML, :xhtml
1235
- ps = Meteor::Ml::Xhtml::ParserImpl.new
1236
- when Parser::HTML5, :html5
1247
+ ps = Meteor::Ml::Xhtml4::ParserImpl.new
1248
+ when Parser::HTML, :html, Parser::HTML5, :html5
1237
1249
  ps = Meteor::Ml::Html5::ParserImpl.new
1238
1250
  when Parser::XHTML5, :xhtml5
1239
1251
  ps = Meteor::Ml::Xhtml5::ParserImpl.new
@@ -1247,9 +1259,9 @@ module Meteor
1247
1259
 
1248
1260
  end
1249
1261
 
1250
- private :bind_str_2
1262
+ private :link_str_2
1251
1263
 
1252
- alias :paraser_str :bind_str
1264
+ alias :paraser_str :link_str
1253
1265
 
1254
1266
  #
1255
1267
  # set parser (パーサをセットする)
@@ -1281,46 +1293,49 @@ module Meteor
1281
1293
  #
1282
1294
  # set options (オプションをセットする)
1283
1295
  # @param [Hash] opts option (オプション)
1284
- # @option opts [String] :base_dir base directory (基準ディレクトリ)
1285
- # @option opts [String] :base_enc default character encoding (デフォルト文字エンコーディング)
1286
- # @option opts [FixNum] :base_type default type of parser (デフォルトのパーサ・タイプ)
1296
+ # @option opts [String] :root root directory (基準ディレクトリ)
1297
+ # @option @deprecated opts [String] :base_dir root directory (基準ディレクトリ)
1298
+ # @option opts [String] :enc default character encoding (デフォルト文字エンコーディング)
1299
+ # @option @deprecated opts [String] :base_enc default character encoding (デフォルト文字エンコーディング)
1300
+ # @option opts [FixNum,Symbol] :type default type of parser (デフォルトのパーサ・タイプ)
1301
+ # @option @deprecated opts [FixNum | Symbol] :base_type default type of parser (デフォルトのパーサ・タイプ)
1287
1302
  #
1288
1303
  def self.options=(opts)
1289
1304
  @@pf.options = opts
1290
1305
  end
1291
1306
 
1292
1307
  #
1293
- #@overload bind(type,relative_path,enc)
1308
+ #@overload link(type,relative_path,enc)
1294
1309
  # generate parser (パーサを作成する)
1295
1310
  # @param [Fixnum] type type of parser (パーサ・タイプ)
1296
1311
  # @param [String] relative_path relative file path (相対ファイルパス)
1297
1312
  # @param [String] enc character encoding (エンコーディング)
1298
1313
  # @return [Meteor::Parser] parser (パーサ)
1299
- #@overload bind(type,relative_path)
1314
+ #@overload link(type,relative_path)
1300
1315
  # generate parser (パーサを作成する)
1301
1316
  # @param [Fixnum] type type of parser (パーサ・タイプ)
1302
1317
  # @param [String] relative_path relative file path (相対ファイルパス)
1303
1318
  # @return [Meteor::Parser] parser (パーサ)
1304
1319
  #
1305
- def self.bind(*args)
1306
- @@pf.bind(*args)
1320
+ def self.link(*args)
1321
+ @@pf.link(*args)
1307
1322
  end
1308
1323
 
1309
1324
  #
1310
- # @overload bind_str(type, relative_url, doc)
1325
+ # @overload link_str(type, relative_url, doc)
1311
1326
  # generate parser (パーサを作成する)
1312
1327
  # @param [Fixnum] type type of parser (パーサ・タイプ)
1313
1328
  # @param [String] relative_url relative URL (相対URL)
1314
1329
  # @param [String] doc document (ドキュメント)
1315
1330
  # @return [Meteor::Parser] parser (パーサ)
1316
- # @overload bind_str(relative_url, doc)
1331
+ # @overload link_str(relative_url, doc)
1317
1332
  # generate parser (パーサを作成する)
1318
1333
  # @param [String] relative_url relative URL (相対URL)
1319
1334
  # @param [String] doc document (ドキュメント)
1320
1335
  # @return [Meteor::Parser] parser (パーサ)
1321
1336
  #
1322
- def self.bind_str(*args)
1323
- @@pf.bind_str(args)
1337
+ def self.link_str(*args)
1338
+ @@pf.link_str(args)
1324
1339
  end
1325
1340
 
1326
1341
  #
@@ -1738,6 +1753,8 @@ module Meteor
1738
1753
  @element_cache = Hash.new
1739
1754
  #フックドキュメント
1740
1755
  @document_hook = ''
1756
+
1757
+ @error_check = true
1741
1758
  end
1742
1759
 
1743
1760
  #
@@ -1927,18 +1944,27 @@ module Meteor
1927
1944
  def element_with_1(tag)
1928
1945
 
1929
1946
  @elm_ = Meteor::Element.new(tag)
1930
- #属性
1931
- @elm_.attributes = @res[2]
1932
- #内容
1933
- @elm_.mixed_content = @res[3]
1934
- #全体
1935
- @elm_.document = @res[0]
1936
1947
 
1948
+ unless @on_search
1949
+ #属性
1950
+ @elm_.attributes = @res[2]
1951
+ #内容
1952
+ @elm_.mixed_content = @res[3]
1953
+ #全体
1954
+ @elm_.document = @res[0]
1955
+ else
1956
+ #属性
1957
+ @elm_.attributes = @res[1]
1958
+ #内容
1959
+ @elm_.mixed_content = @res[2]
1960
+ #全体
1961
+ @elm_.document = @res[0]
1962
+ end
1963
+ #内容あり要素検索用パターン
1937
1964
  #@pattern_cc = '' << TAG_OPEN << @_tag << TAG_SEARCH_NC_1_1 << @_tag
1938
1965
  #@pattern_cc << TAG_SEARCH_NC_1_2 << @_tag << TAG_CLOSE
1939
- @pattern_cc = "<#{@_tag}(?:|\\s[^<>]*)>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
1966
+ @pattern_cc = "<#{@_tag}(|\\s[^<>]*)>(((?!(#{@_tag}[^<>]*>)).)*)<\\/#{@_tag}>"
1940
1967
 
1941
- #内容あり要素検索用パターン
1942
1968
  @elm_.pattern = @pattern_cc
1943
1969
 
1944
1970
  @elm_.empty = true
@@ -1958,8 +1984,8 @@ module Meteor
1958
1984
  #全体
1959
1985
  @elm_.document = @res[0]
1960
1986
  #空要素検索用パターン
1961
- @pattern_cc = '' << TAG_OPEN << @_tag << TAG_SEARCH_NC_1_3
1962
- #@pattern_cc = "<#{@_tag}(?:|\\s[^<>]*)\\/>"
1987
+ @pattern_cc = '' << TAG_OPEN << @_tag << TAG_SEARCH_1_3
1988
+ #@pattern_cc = "<#{@_tag}(|\\s[^<>]*)\\/>"
1963
1989
  @elm_.pattern = @pattern_cc
1964
1990
 
1965
1991
  @elm_.empty = false
@@ -2021,7 +2047,9 @@ module Meteor
2021
2047
  #@pattern_cc = @pattern_cc_2
2022
2048
  element_with_3_1(tag)
2023
2049
  else
2024
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
2050
+ if @error_check
2051
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
2052
+ end
2025
2053
  @elm_ = nil
2026
2054
  end
2027
2055
 
@@ -2046,6 +2074,7 @@ module Meteor
2046
2074
  private :element_quote_3
2047
2075
 
2048
2076
  def element_with_3_1(tag)
2077
+ #puts @res.captures.length
2049
2078
  case @res.captures.length
2050
2079
  when FOUR
2051
2080
  #要素
@@ -2060,7 +2089,7 @@ module Meteor
2060
2089
  #@pattern_cc = ''<< TAG_OPEN << @_tag << TAG_SEARCH_NC_2_1 << @_attr_name << ATTR_EQ
2061
2090
  #@pattern_cc << @_attr_value << TAG_SEARCH_NC_2_2 << @_tag
2062
2091
  #@pattern_cc << TAG_SEARCH_NC_1_2 << @_tag << TAG_CLOSE
2063
- @pattern_cc = "<#{@_tag}\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
2092
+ @pattern_cc = "<#{@_tag}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>(((?!(#{@_tag}[^<>]*>)).)*)<\\/#{@_tag}>"
2064
2093
 
2065
2094
  @elm_.pattern = @pattern_cc
2066
2095
 
@@ -2081,7 +2110,7 @@ module Meteor
2081
2110
  #@pattern_cc = ''<< TAG_OPEN << @_tag << TAG_SEARCH_NC_2_1 << @_attr_name << ATTR_EQ
2082
2111
  #@pattern_cc << @_attr_value << TAG_SEARCH_NC_2_2 << @_tag
2083
2112
  #@pattern_cc << TAG_SEARCH_NC_1_2 << @_tag << TAG_CLOSE
2084
- @pattern_cc = "<#{@_tag}\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
2113
+ @pattern_cc = "<#{@_tag}(\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}\"[^<>]*)>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
2085
2114
 
2086
2115
  @elm_.pattern = @pattern_cc
2087
2116
 
@@ -2092,10 +2121,17 @@ module Meteor
2092
2121
  when THREE,SIX
2093
2122
  #内容
2094
2123
  @elm_ = Meteor::Element.new(tag)
2095
- #属性
2096
- @elm_.attributes = @res[1].chop
2097
- #内容
2098
- @elm_.mixed_content = @res[3]
2124
+ unless @on_search
2125
+ #属性
2126
+ @elm_.attributes = @res[1].chop
2127
+ #内容
2128
+ @elm_.mixed_content = @res[3]
2129
+ else
2130
+ #属性
2131
+ @elm_.attributes = @res[1].chop
2132
+ #内容
2133
+ @elm_.mixed_content = @res[3]
2134
+ end
2099
2135
  #全体
2100
2136
  @elm_.document = @res[0]
2101
2137
  #内容あり要素検索用パターン
@@ -2171,7 +2207,7 @@ module Meteor
2171
2207
  private :element_pattern_with_3_2
2172
2208
 
2173
2209
  def element_without_3(tag)
2174
- element_without_3_1(tag, TAG_SEARCH_NC_2_3_2)
2210
+ element_without_3_1(tag, TAG_SEARCH_2_3_2)
2175
2211
  end
2176
2212
 
2177
2213
  private :element_without_3
@@ -2185,7 +2221,7 @@ module Meteor
2185
2221
  #全体
2186
2222
  @elm_.document = @res[0]
2187
2223
  #空要素検索用パターン
2188
- @pattern_cc = '' << TAG_OPEN << @_tag << TAG_SEARCH_NC_2_1 << @_attr_name << ATTR_EQ << @_attr_value << closer
2224
+ @pattern_cc = '' << TAG_OPEN << @_tag << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ << @_attr_value << closer
2189
2225
  #@pattern_cc = "<#{@_tag}\\s[^<>]*#{@_attr_name}=\"#{@_attr_value}#{closer}"
2190
2226
  @elm_.pattern = @pattern_cc
2191
2227
 
@@ -2214,7 +2250,9 @@ module Meteor
2214
2250
  if @res
2215
2251
  element_3(@res[1], attr_name, attr_value)
2216
2252
  else
2217
- puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
2253
+ if @error_check
2254
+ puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
2255
+ end
2218
2256
  @elm_ = nil
2219
2257
  end
2220
2258
  #=end
@@ -2261,7 +2299,9 @@ module Meteor
2261
2299
  #@pattern_cc = @pattern_cc_2
2262
2300
  element_with_2_1
2263
2301
  else
2264
- puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
2302
+ if @error_check
2303
+ puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
2304
+ end
2265
2305
  @elm_ = nil
2266
2306
  end
2267
2307
  =end
@@ -2490,7 +2530,9 @@ module Meteor
2490
2530
  #@pattern_cc = @pattern_cc_2
2491
2531
  element_with_5_1(tag)
2492
2532
  else
2493
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
2533
+ if @error_check
2534
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
2535
+ end
2494
2536
  @elm_ = nil
2495
2537
  end
2496
2538
 
@@ -2529,7 +2571,7 @@ module Meteor
2529
2571
  #@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_6 << @_attr_name1 << ATTR_EQ
2530
2572
  #@pattern_cc << @_attr_value1 << TAG_SEARCH_NC_2_2_2 << @_tag
2531
2573
  #@pattern_cc << TAG_SEARCH_NC_1_2 << @_tag << TAG_CLOSE
2532
- @pattern_cc = "<#{@_tag}\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
2574
+ @pattern_cc = "<#{@_tag}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_tag}[^<>]*>)).)*)<\\/#{@_tag}>"
2533
2575
 
2534
2576
  @elm_.pattern = @pattern_cc
2535
2577
  #
@@ -2552,7 +2594,7 @@ module Meteor
2552
2594
  #@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_6 << @_attr_name1 << ATTR_EQ
2553
2595
  #@pattern_cc << @_attr_value1 << TAG_SEARCH_NC_2_2_2 << @_tag
2554
2596
  #@pattern_cc << TAG_SEARCH_NC_1_2 << @_tag << TAG_CLOSE
2555
- @pattern_cc = "<#{@_tag}\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*>((?!(#{@_tag}[^<>]*>)).)*<\\/#{@_tag}>"
2597
+ @pattern_cc = "<#{@_tag}(\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}\")[^<>]*)>(((?!(#{@_tag}[^<>]*>)).)*)<\\/#{@_tag}>"
2556
2598
 
2557
2599
  @elm_.pattern = @pattern_cc
2558
2600
  #
@@ -2651,7 +2693,7 @@ module Meteor
2651
2693
  private :element_pattern_with_5_2
2652
2694
 
2653
2695
  def element_without_5(tag)
2654
- element_without_5_1(tag, TAG_SEARCH_NC_2_3_2_2)
2696
+ element_without_5_1(tag, TAG_SEARCH_2_3_2_2)
2655
2697
  end
2656
2698
 
2657
2699
  private :element_without_5
@@ -2670,7 +2712,7 @@ module Meteor
2670
2712
  #@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_7 << @_attr_name2 << ATTR_EQ
2671
2713
  #@pattern_cc << @_attr_value2 << TAG_SEARCH_NC_2_6 << @_attr_name1 << ATTR_EQ
2672
2714
  #@pattern_cc << @_attr_value1 << closer
2673
- @pattern_cc = "<#{@_tag}\\s[^<>]*(?:#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}#{closer}"
2715
+ @pattern_cc = "<#{@_tag}(\\s[^<>]*(#{@_attr_name1}=\"#{@_attr_value1}\"[^<>]*#{@_attr_name2}=\"#{@_attr_value2}\"|#{@_attr_name2}=\"#{@_attr_value2}\"[^<>]*#{@_attr_name1}=\"#{@_attr_value1}#{closer}"
2674
2716
 
2675
2717
  @elm_.pattern = @pattern_cc
2676
2718
 
@@ -2702,7 +2744,9 @@ module Meteor
2702
2744
  #@elm_ = element_5(@res[1], attr_name1, attr_value1,attr_name2, attr_value2)
2703
2745
  element_5(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
2704
2746
  else
2705
- puts Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
2747
+ if @error_check
2748
+ puts Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
2749
+ end
2706
2750
  @elm_ = nil
2707
2751
  end
2708
2752
 
@@ -2999,6 +3043,8 @@ module Meteor
2999
3043
  def elements_(*args)
3000
3044
  elm_arr = Array.new
3001
3045
 
3046
+ @on_search = true
3047
+
3002
3048
  case args.size
3003
3049
  when ONE
3004
3050
  @elm_ = element_1(*args)
@@ -3016,15 +3062,18 @@ module Meteor
3016
3062
  return elm_arr
3017
3063
  end
3018
3064
 
3019
- @patten_cc = @elm_.pattern
3065
+ @pattern_cc = @elm_.pattern
3066
+
3067
+ #puts @pattern_cc
3020
3068
 
3021
- @patten = Meteor::Core::Util::PatternCache.get(@pattern_cc)
3069
+ @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
3022
3070
 
3023
3071
  @position = 0
3024
3072
 
3025
3073
  while (@res = @pattern.match(@root.document,@position))
3026
-
3027
- if @res
3074
+ @position = @res.end(0)
3075
+ #puts @res[0]
3076
+ #if @res
3028
3077
  case args.size
3029
3078
  when ONE
3030
3079
  if @elm_.empty
@@ -3051,10 +3100,10 @@ module Meteor
3051
3100
 
3052
3101
  @element_cache.store(@elm_.object_id, @elm_)
3053
3102
 
3054
- @position = @res.end(0)
3055
- else
3056
- break
3057
- end
3103
+ @on_search = false
3104
+ #else
3105
+ # break
3106
+ #end
3058
3107
  end
3059
3108
 
3060
3109
  elm_arr
@@ -3163,13 +3212,21 @@ module Meteor
3163
3212
  when ZERO
3164
3213
  get_attr_value(elm, attr.to_s)
3165
3214
  when ONE
3166
- elm.document_sync = true
3167
- set_attribute_3(elm, attr.to_s,args[0])
3215
+ if args[0] != nil
3216
+ elm.document_sync = true
3217
+ set_attribute_3(elm, attr.to_s,args[0])
3218
+ else
3219
+ remove_attr(elm, attr.to_s)
3220
+ end
3168
3221
  end
3169
3222
 
3170
3223
  elsif attr.kind_of?(Hash) && attr.size == 1
3171
- elm.document_sync = true
3172
- set_attribute_3(elm, attr.keys[0].to_s, attr.values[0])
3224
+ if attr.values[0] != nil
3225
+ elm.document_sync = true
3226
+ set_attribute_3(elm, attr.keys[0].to_s, attr.values[0])
3227
+ else
3228
+ remove_attr(elm, attr.keys[0].to_s)
3229
+ end
3173
3230
  #elsif attrs.kind_of?(Hash) && attrs.size >= 1
3174
3231
  # elm.document_sync = true
3175
3232
  # attrs.each{|name,value|
@@ -3418,13 +3475,13 @@ module Meteor
3418
3475
  when TWO
3419
3476
  #if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String)
3420
3477
  args[0].document_sync = true
3421
- set_content_2(args[0], args[1])
3478
+ set_content_2(args[0], args[1].to_s)
3422
3479
  #else
3423
3480
  # raise ArgumentError
3424
3481
  #end
3425
3482
  when THREE
3426
3483
  args[0].document_sync = true
3427
- set_content_3(args[0], args[1], args[2])
3484
+ set_content_3(args[0], args[1].to_s, args[2])
3428
3485
  else
3429
3486
  raise ArgumentError
3430
3487
  end
@@ -3499,8 +3556,6 @@ module Meteor
3499
3556
  elm
3500
3557
  end
3501
3558
 
3502
- private :remove_attr
3503
-
3504
3559
  def remove_attrs_(elm, attr_name)
3505
3560
  #属性検索用パターン
3506
3561
  @pattern = Meteor::Core::Util::PatternCache.get('' << attr_name << ERASE_ATTR_1)
@@ -3681,7 +3736,7 @@ module Meteor
3681
3736
  #
3682
3737
  # reflect (反映する)
3683
3738
  #
3684
- def flush
3739
+ def flash
3685
3740
 
3686
3741
  if self.element_hook
3687
3742
  if self.element_hook.origin.mono
@@ -3691,11 +3746,15 @@ module Meteor
3691
3746
  #@root.hookDocument << @root.element.mixed_content << SET_CX_3
3692
3747
  #@root.hookDocument << @root.element.tag << SET_CX_4
3693
3748
  self.document_hook << "<!-- @#{self.element_hook.tag} #{self.element_hook.attributes}-->#{self.element_hook.mixed_content}<!-- /@#{self.element_hook.tag} -->"
3749
+
3750
+ #self.document_hook << @root.kaigyo_code << "<!-- @#{self.element_hook.tag} #{self.element_hook.attributes}-->#{self.element_hook.mixed_content}<!-- /@#{self.element_hook.tag} -->"
3694
3751
  else
3695
3752
  #@root.hookDocument << TAG_OPEN << @root.element.tag
3696
3753
  #@root.hookDocument << @root.element.attributes << TAG_CLOSE << @root.element.mixed_content
3697
3754
  #@root.hookDocument << TAG_OPEN3 << @root.element.tag << TAG_CLOSE
3698
3755
  self.document_hook << "<#{self.element_hook.tag}#{self.element_hook.attributes}>#{self.element_hook.mixed_content}</#{self.element_hook.tag}>"
3756
+
3757
+ #self.document_hook << @root.kaigyo_code << "<#{self.element_hook.tag}#{self.element_hook.attributes}>#{self.element_hook.mixed_content}</#{self.element_hook.tag}>"
3699
3758
  end
3700
3759
  self.element_hook = Element.new!(self.element_hook.origin, self)
3701
3760
  else
@@ -3708,11 +3767,15 @@ module Meteor
3708
3767
  #@root.hookDocument << @root.document << SET_CX_3
3709
3768
  #@root.hookDocument << @root.element.tag << SET_CX_4
3710
3769
  self.document_hook << "<!-- @#{self.element_hook.tag} #{@_attributes}-->#{@root.document}<!-- /@#{self.element_hook.tag} -->"
3770
+
3771
+ #self.document_hook << @root.kaigyo_code << "<!-- @#{self.element_hook.tag} #{@_attributes}-->#{@root.document}<!-- /@#{self.element_hook.tag} -->"
3711
3772
  else
3712
3773
  #@root.hookDocument << TAG_OPEN << @root.element.tag
3713
3774
  #@root.hookDocument << @_attributes << TAG_CLOSE << @root.document
3714
3775
  #@root.hookDocument << TAG_OPEN3 << @root.element.tag << TAG_CLOSE
3715
3776
  self.document_hook << "<#{self.element_hook.tag}#{@_attributes}>#{@root.document}</#{self.element_hook.tag}>"
3777
+
3778
+ #self.document_hook << @root.kaigyo_code << "<#{self.element_hook.tag}#{@_attributes}>#{@root.document}</#{self.element_hook.tag}>"
3716
3779
  end
3717
3780
  self.element_hook = Element.new!(self.element_hook.origin, self)
3718
3781
  end
@@ -3756,6 +3819,7 @@ module Meteor
3756
3819
  else
3757
3820
  pif2.root_element.document = String.new(elm.document)
3758
3821
  end
3822
+ pif2.root_element.kaigyo_code = elm.parser.root_element.kaigyo_code
3759
3823
 
3760
3824
  @elm_
3761
3825
  end
@@ -3826,11 +3890,11 @@ module Meteor
3826
3890
 
3827
3891
  def create(pif)
3828
3892
  case pif.doc_type
3829
- when Parser::HTML
3830
- Meteor::Ml::Html::ParserImpl.new
3831
- when Parser::XHTML
3832
- Meteor::Ml::Xhtml::ParserImpl.new
3833
- when Parser::HTML5
3893
+ when Parser::HTML4
3894
+ Meteor::Ml::Html4::ParserImpl.new
3895
+ when Parser::XHTML4
3896
+ Meteor::Ml::Xhtml4::ParserImpl.new
3897
+ when Parser::HTML, Parser::HTML5
3834
3898
  Meteor::Ml::Html5::ParserImpl.new
3835
3899
  when Parser::XHTML5
3836
3900
  Meteor::Ml::Xhtml5::ParserImpl.new
@@ -3952,10 +4016,10 @@ module Meteor
3952
4016
  end
3953
4017
 
3954
4018
  module Ml
3955
- module Html
4019
+ module Html4
3956
4020
 
3957
4021
  #
3958
- # HTML parser (HTMLパーサ)
4022
+ # HTML4 parser (HTMLパーサ)
3959
4023
  #
3960
4024
  class ParserImpl < Meteor::Core::Kernel
3961
4025
 
@@ -4091,7 +4155,7 @@ module Meteor
4091
4155
  #
4092
4156
  def initialize(*args)
4093
4157
  super()
4094
- @doc_type = Parser::HTML
4158
+ @doc_type = Parser::HTML4
4095
4159
  case args.length
4096
4160
  when ZERO
4097
4161
  #initialize_0
@@ -4156,12 +4220,16 @@ module Meteor
4156
4220
  # analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
4157
4221
  #
4158
4222
  def analyze_content_type
4223
+ @error_check = false
4224
+
4159
4225
  element_3(META_S, HTTP_EQUIV, CONTENT_TYPE)
4160
4226
 
4161
4227
  if !@elm_
4162
4228
  element_3(META, HTTP_EQUIV, CONTENT_TYPE)
4163
4229
  end
4164
4230
 
4231
+ @error_check = true
4232
+
4165
4233
  if @elm_
4166
4234
  @root.content_type = @elm_.attr(CONTENT)
4167
4235
  else
@@ -4180,6 +4248,7 @@ module Meteor
4180
4248
  for a in KAIGYO_CODE
4181
4249
  if @root.document.include?(a)
4182
4250
  @root.kaigyo_code = a
4251
+ #puts "kaigyo:" << @root.kaigyo_code
4183
4252
  end
4184
4253
  end
4185
4254
 
@@ -4205,7 +4274,9 @@ module Meteor
4205
4274
  if @res
4206
4275
  element_without_1(tag)
4207
4276
  else
4208
- puts Meteor::Exception::NoSuchElementException.new(tag).message
4277
+ if @error_check
4278
+ puts Meteor::Exception::NoSuchElementException.new(tag).message
4279
+ end
4209
4280
  @elm_ = nil
4210
4281
  end
4211
4282
  else
@@ -4221,7 +4292,9 @@ module Meteor
4221
4292
  if @res
4222
4293
  element_with_1(tag)
4223
4294
  else
4224
- puts Meteor::Exception::NoSuchElementException.new(tag).message
4295
+ if @error_check
4296
+ puts Meteor::Exception::NoSuchElementException.new(tag).message
4297
+ end
4225
4298
  @elm_ = nil
4226
4299
  end
4227
4300
  end
@@ -4269,7 +4342,9 @@ module Meteor
4269
4342
  if @res
4270
4343
  element_without_3(tag)
4271
4344
  else
4272
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
4345
+ if @error_check
4346
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
4347
+ end
4273
4348
  @elm_ = nil
4274
4349
  end
4275
4350
  else
@@ -4290,7 +4365,9 @@ module Meteor
4290
4365
  if @res
4291
4366
  element_with_3_1(tag)
4292
4367
  else
4293
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
4368
+ if @error_check
4369
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name, attr_value).message
4370
+ end
4294
4371
  @elm_ = nil
4295
4372
  end
4296
4373
  end
@@ -4301,7 +4378,7 @@ module Meteor
4301
4378
  private :element_3
4302
4379
 
4303
4380
  def element_without_3(tag)
4304
- element_without_3_1(tag, TAG_SEARCH_NC_2_4_3)
4381
+ element_without_3_1(tag, TAG_SEARCH_2_4_3)
4305
4382
  end
4306
4383
 
4307
4384
  private :element_without_3
@@ -4326,7 +4403,9 @@ module Meteor
4326
4403
  if @res
4327
4404
  element_3(@res[1], attr_name, attr_value)
4328
4405
  else
4329
- puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
4406
+ if @error_check
4407
+ puts Meteor::Exception::NoSuchElementException.new(attr_name, attr_value).message
4408
+ end
4330
4409
  @elm_ = nil
4331
4410
  end
4332
4411
 
@@ -4365,7 +4444,9 @@ module Meteor
4365
4444
  if @res
4366
4445
  element_without_5(tag)
4367
4446
  else
4368
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name1, attr_value1, attr_name2, attr_value2).message
4447
+ if @error_check
4448
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name1, attr_value1, attr_name2, attr_value2).message
4449
+ end
4369
4450
  @elm_ = nil
4370
4451
  end
4371
4452
  else
@@ -4389,7 +4470,9 @@ module Meteor
4389
4470
  if @res
4390
4471
  element_with_5_1(tag)
4391
4472
  else
4392
- puts Meteor::Exception::NoSuchElementException.new(tag, attr_name1, attr_value1, attr_name2, attr_value2).message
4473
+ if @error_check
4474
+ puts Meteor::Exception::NoSuchElementException.new(tag, attr_name1, attr_value1, attr_name2, attr_value2).message
4475
+ end
4393
4476
  @elm_ = nil
4394
4477
  end
4395
4478
  end
@@ -4400,7 +4483,7 @@ module Meteor
4400
4483
  private :element_5
4401
4484
 
4402
4485
  def element_without_5(tag)
4403
- element_without_5_1(tag, TAG_SEARCH_NC_2_4_3_2)
4486
+ element_without_5_1(tag, TAG_SEARCH_2_4_3_2)
4404
4487
  end
4405
4488
 
4406
4489
  private :element_without_5
@@ -4432,7 +4515,9 @@ module Meteor
4432
4515
  if @res
4433
4516
  element_5(@res[1], attr_name1, attr_value1, attr_name2, attr_value2)
4434
4517
  else
4435
- puts Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
4518
+ if @error_check
4519
+ puts Meteor::Exception::NoSuchElementException.new(attr_name1, attr_value1, attr_name2, attr_value2).message
4520
+ end
4436
4521
  @elm_ = nil
4437
4522
  end
4438
4523
 
@@ -4654,10 +4739,10 @@ module Meteor
4654
4739
 
4655
4740
  end
4656
4741
 
4657
- module Xhtml
4742
+ module Xhtml4
4658
4743
 
4659
4744
  #
4660
- # XHTML parser (XHTMLパーサ)
4745
+ # XHTML4 parser (XHTML4パーサ)
4661
4746
  #
4662
4747
  class ParserImpl < Meteor::Core::Kernel
4663
4748
 
@@ -4794,7 +4879,7 @@ module Meteor
4794
4879
  #
4795
4880
  def initialize(*args)
4796
4881
  super()
4797
- @doc_type = Parser::XHTML
4882
+ @doc_type = Parser::XHTML4
4798
4883
  case args.length
4799
4884
  when ZERO
4800
4885
  #initialize_0
@@ -4858,12 +4943,16 @@ module Meteor
4858
4943
  # analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
4859
4944
  #
4860
4945
  def analyze_content_type
4946
+ @error_check = false
4947
+
4861
4948
  element_3(META_S, HTTP_EQUIV, CONTENT_TYPE)
4862
4949
 
4863
4950
  if !@elm_
4864
4951
  element_3(META, HTTP_EQUIV, CONTENT_TYPE)
4865
4952
  end
4866
4953
 
4954
+ @error_check = true
4955
+
4867
4956
  if @elm_
4868
4957
  @root.content_type = @elm_.attr(CONTENT)
4869
4958
  else
@@ -5093,7 +5182,7 @@ module Meteor
5093
5182
  #
5094
5183
  # HTML5 parser (HTML5パーサ)
5095
5184
  #
5096
- class ParserImpl < Meteor::Ml::Html::ParserImpl
5185
+ class ParserImpl < Meteor::Ml::Html4::ParserImpl
5097
5186
 
5098
5187
  CHARSET = 'charset'.freeze
5099
5188
  UTF8 = 'utf-8'.freeze
@@ -5164,12 +5253,16 @@ module Meteor
5164
5253
  # analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
5165
5254
  #
5166
5255
  def analyze_content_type
5256
+ @error_check = false
5257
+
5167
5258
  element_3(META_S, HTTP_EQUIV, CONTENT_TYPE)
5168
5259
 
5169
5260
  if !@elm_
5170
5261
  element_3(META, HTTP_EQUIV, CONTENT_TYPE)
5171
5262
  end
5172
5263
 
5264
+ @error_check = true
5265
+
5173
5266
  if @elm_
5174
5267
  @root.content_type = @elm_.attr(CONTENT)
5175
5268
  @root.charset = @elm_.attr(CHARSET)
@@ -5233,7 +5326,7 @@ module Meteor
5233
5326
  #
5234
5327
  # XHTML5 parser (XHTML5パーサ)
5235
5328
  #
5236
- class ParserImpl < Meteor::Ml::Xhtml::ParserImpl
5329
+ class ParserImpl < Meteor::Ml::Xhtml4::ParserImpl
5237
5330
 
5238
5331
  CHARSET = 'charset'.freeze
5239
5332
  UTF8 = 'utf-8'.freeze
@@ -5300,12 +5393,16 @@ module Meteor
5300
5393
  # analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
5301
5394
  #
5302
5395
  def analyze_content_type
5396
+ @error_check = false
5397
+
5303
5398
  element_3(META_S, HTTP_EQUIV, CONTENT_TYPE)
5304
5399
 
5305
5400
  if !@elm_
5306
5401
  element_3(META, HTTP_EQUIV, CONTENT_TYPE)
5307
5402
  end
5308
5403
 
5404
+ @error_check = true
5405
+
5309
5406
  if @elm_
5310
5407
  @root.content_type = @elm_.attr(CONTENT)
5311
5408
  @root.charset = @elm_.attr(CHARSET)
@@ -5373,6 +5470,9 @@ module Meteor
5373
5470
  #
5374
5471
  class ParserImpl < Meteor::Core::Kernel
5375
5472
 
5473
+ #KAIGYO_CODE = "\r?\n|\r".freeze
5474
+ KAIGYO_CODE = ["\r\n".freeze, "\n".freeze, "\r".freeze]
5475
+
5376
5476
  PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt);'.freeze
5377
5477
 
5378
5478
  @@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
@@ -5427,13 +5527,50 @@ module Meteor
5427
5527
 
5428
5528
  private :initialize_1
5429
5529
 
5530
+
5531
+ #
5532
+ # parse document (ドキュメントを解析する)
5533
+ #
5534
+ def parse
5535
+ analyze_ml
5536
+ end
5537
+
5538
+ #
5539
+ # analyze document (ドキュメントをパースする)
5540
+ #
5541
+ def analyze_ml
5542
+ #改行コードの取得
5543
+ analyze_kaigyo_code
5544
+
5545
+ @res = nil
5546
+ end
5547
+
5548
+ private :analyze_ml
5549
+
5550
+ #
5430
5551
  # get content type (コンテントタイプを取得する)
5431
- # @return [Streing] content type (コンテントタイプ)
5552
+ # @return [String] conent type (コンテントタイプ)
5432
5553
  #
5433
5554
  def content_type
5434
5555
  @root.content_type
5435
5556
  end
5436
5557
 
5558
+ #
5559
+ # analuze document , set newline (ドキュメントをパースし、改行コードをセットする)
5560
+ #
5561
+ def analyze_kaigyo_code
5562
+ #改行コード取得
5563
+
5564
+ for a in KAIGYO_CODE
5565
+ if @root.document.include?(a)
5566
+ @root.kaigyo_code = a
5567
+ #puts "kaigyo:" << @root.kaigyo_code
5568
+ end
5569
+ end
5570
+
5571
+ end
5572
+
5573
+ private :analyze_kaigyo_code
5437
5574
 
5438
5575
  def escape(content)
5439
5576
  #特殊文字の置換