rubysl-rexml 1.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/lib/rexml/attlistdecl.rb +56 -56
  4. data/lib/rexml/attribute.rb +155 -149
  5. data/lib/rexml/cdata.rb +48 -48
  6. data/lib/rexml/child.rb +82 -82
  7. data/lib/rexml/comment.rb +59 -59
  8. data/lib/rexml/doctype.rb +22 -24
  9. data/lib/rexml/document.rb +185 -129
  10. data/lib/rexml/dtd/attlistdecl.rb +7 -7
  11. data/lib/rexml/dtd/dtd.rb +41 -41
  12. data/lib/rexml/dtd/elementdecl.rb +13 -13
  13. data/lib/rexml/dtd/entitydecl.rb +49 -49
  14. data/lib/rexml/dtd/notationdecl.rb +32 -32
  15. data/lib/rexml/element.rb +122 -107
  16. data/lib/rexml/encoding.rb +37 -58
  17. data/lib/rexml/entity.rb +144 -144
  18. data/lib/rexml/formatters/default.rb +6 -4
  19. data/lib/rexml/formatters/pretty.rb +11 -8
  20. data/lib/rexml/formatters/transitive.rb +4 -3
  21. data/lib/rexml/functions.rb +33 -21
  22. data/lib/rexml/instruction.rb +49 -49
  23. data/lib/rexml/light/node.rb +190 -191
  24. data/lib/rexml/namespace.rb +39 -39
  25. data/lib/rexml/node.rb +38 -38
  26. data/lib/rexml/output.rb +17 -12
  27. data/lib/rexml/parent.rb +26 -25
  28. data/lib/rexml/parseexception.rb +4 -4
  29. data/lib/rexml/parsers/baseparser.rb +90 -61
  30. data/lib/rexml/parsers/lightparser.rb +41 -43
  31. data/lib/rexml/parsers/pullparser.rb +1 -1
  32. data/lib/rexml/parsers/sax2parser.rb +233 -198
  33. data/lib/rexml/parsers/streamparser.rb +6 -2
  34. data/lib/rexml/parsers/treeparser.rb +9 -6
  35. data/lib/rexml/parsers/ultralightparser.rb +40 -40
  36. data/lib/rexml/parsers/xpathparser.rb +51 -52
  37. data/lib/rexml/quickpath.rb +247 -248
  38. data/lib/rexml/rexml.rb +9 -10
  39. data/lib/rexml/sax2listener.rb +92 -92
  40. data/lib/rexml/security.rb +27 -0
  41. data/lib/rexml/source.rb +95 -50
  42. data/lib/rexml/streamlistener.rb +90 -90
  43. data/lib/rexml/syncenumerator.rb +3 -4
  44. data/lib/rexml/text.rb +157 -76
  45. data/lib/rexml/validation/relaxng.rb +18 -18
  46. data/lib/rexml/validation/validation.rb +5 -5
  47. data/lib/rexml/xmldecl.rb +59 -63
  48. data/lib/rexml/xmltokens.rb +14 -14
  49. data/lib/rexml/xpath.rb +67 -53
  50. data/lib/rexml/xpath_parser.rb +49 -38
  51. data/lib/rubysl/rexml.rb +1 -0
  52. data/lib/rubysl/rexml/version.rb +1 -1
  53. data/rubysl-rexml.gemspec +3 -1
  54. metadata +19 -28
  55. data/lib/rexml/encodings/CP-1252.rb +0 -103
  56. data/lib/rexml/encodings/EUC-JP.rb +0 -35
  57. data/lib/rexml/encodings/ICONV.rb +0 -22
  58. data/lib/rexml/encodings/ISO-8859-1.rb +0 -7
  59. data/lib/rexml/encodings/ISO-8859-15.rb +0 -72
  60. data/lib/rexml/encodings/SHIFT-JIS.rb +0 -37
  61. data/lib/rexml/encodings/SHIFT_JIS.rb +0 -1
  62. data/lib/rexml/encodings/UNILE.rb +0 -34
  63. data/lib/rexml/encodings/US-ASCII.rb +0 -30
  64. data/lib/rexml/encodings/UTF-16.rb +0 -35
  65. data/lib/rexml/encodings/UTF-8.rb +0 -18
@@ -1,103 +0,0 @@
1
- #
2
- # This class was contributed by Mikko Tiihonen mikko DOT tiihonen AT hut DOT fi
3
- #
4
- module REXML
5
- module Encoding
6
- register( "CP-1252" ) do |o|
7
- class << o
8
- alias encode encode_cp1252
9
- alias decode decode_cp1252
10
- end
11
- end
12
-
13
- # Convert from UTF-8
14
- def encode_cp1252(content)
15
- array_utf8 = content.unpack('U*')
16
- array_enc = []
17
- array_utf8.each do |num|
18
- case num
19
- # shortcut first bunch basic characters
20
- when 0..0xFF; array_enc << num
21
- # characters added compared to iso-8859-1
22
- when 0x20AC; array_enc << 0x80 # 0xe2 0x82 0xac
23
- when 0x201A; array_enc << 0x82 # 0xe2 0x82 0x9a
24
- when 0x0192; array_enc << 0x83 # 0xc6 0x92
25
- when 0x201E; array_enc << 0x84 # 0xe2 0x82 0x9e
26
- when 0x2026; array_enc << 0x85 # 0xe2 0x80 0xa6
27
- when 0x2020; array_enc << 0x86 # 0xe2 0x80 0xa0
28
- when 0x2021; array_enc << 0x87 # 0xe2 0x80 0xa1
29
- when 0x02C6; array_enc << 0x88 # 0xcb 0x86
30
- when 0x2030; array_enc << 0x89 # 0xe2 0x80 0xb0
31
- when 0x0160; array_enc << 0x8A # 0xc5 0xa0
32
- when 0x2039; array_enc << 0x8B # 0xe2 0x80 0xb9
33
- when 0x0152; array_enc << 0x8C # 0xc5 0x92
34
- when 0x017D; array_enc << 0x8E # 0xc5 0xbd
35
- when 0x2018; array_enc << 0x91 # 0xe2 0x80 0x98
36
- when 0x2019; array_enc << 0x92 # 0xe2 0x80 0x99
37
- when 0x201C; array_enc << 0x93 # 0xe2 0x80 0x9c
38
- when 0x201D; array_enc << 0x94 # 0xe2 0x80 0x9d
39
- when 0x2022; array_enc << 0x95 # 0xe2 0x80 0xa2
40
- when 0x2013; array_enc << 0x96 # 0xe2 0x80 0x93
41
- when 0x2014; array_enc << 0x97 # 0xe2 0x80 0x94
42
- when 0x02DC; array_enc << 0x98 # 0xcb 0x9c
43
- when 0x2122; array_enc << 0x99 # 0xe2 0x84 0xa2
44
- when 0x0161; array_enc << 0x9A # 0xc5 0xa1
45
- when 0x203A; array_enc << 0x9B # 0xe2 0x80 0xba
46
- when 0x0152; array_enc << 0x9C # 0xc5 0x93
47
- when 0x017E; array_enc << 0x9E # 0xc5 0xbe
48
- when 0x0178; array_enc << 0x9F # 0xc5 0xb8
49
- else
50
- # all remaining basic characters can be used directly
51
- if num <= 0xFF
52
- array_enc << num
53
- else
54
- # Numeric entity (&#nnnn;); shard by Stefan Scholl
55
- array_enc.concat "&\##{num};".unpack('C*')
56
- end
57
- end
58
- end
59
- array_enc.pack('C*')
60
- end
61
-
62
- # Convert to UTF-8
63
- def decode_cp1252(str)
64
- array_latin9 = str.unpack('C*')
65
- array_enc = []
66
- array_latin9.each do |num|
67
- case num
68
- # characters that added compared to iso-8859-1
69
- when 0x80; array_enc << 0x20AC # 0xe2 0x82 0xac
70
- when 0x82; array_enc << 0x201A # 0xe2 0x82 0x9a
71
- when 0x83; array_enc << 0x0192 # 0xc6 0x92
72
- when 0x84; array_enc << 0x201E # 0xe2 0x82 0x9e
73
- when 0x85; array_enc << 0x2026 # 0xe2 0x80 0xa6
74
- when 0x86; array_enc << 0x2020 # 0xe2 0x80 0xa0
75
- when 0x87; array_enc << 0x2021 # 0xe2 0x80 0xa1
76
- when 0x88; array_enc << 0x02C6 # 0xcb 0x86
77
- when 0x89; array_enc << 0x2030 # 0xe2 0x80 0xb0
78
- when 0x8A; array_enc << 0x0160 # 0xc5 0xa0
79
- when 0x8B; array_enc << 0x2039 # 0xe2 0x80 0xb9
80
- when 0x8C; array_enc << 0x0152 # 0xc5 0x92
81
- when 0x8E; array_enc << 0x017D # 0xc5 0xbd
82
- when 0x91; array_enc << 0x2018 # 0xe2 0x80 0x98
83
- when 0x92; array_enc << 0x2019 # 0xe2 0x80 0x99
84
- when 0x93; array_enc << 0x201C # 0xe2 0x80 0x9c
85
- when 0x94; array_enc << 0x201D # 0xe2 0x80 0x9d
86
- when 0x95; array_enc << 0x2022 # 0xe2 0x80 0xa2
87
- when 0x96; array_enc << 0x2013 # 0xe2 0x80 0x93
88
- when 0x97; array_enc << 0x2014 # 0xe2 0x80 0x94
89
- when 0x98; array_enc << 0x02DC # 0xcb 0x9c
90
- when 0x99; array_enc << 0x2122 # 0xe2 0x84 0xa2
91
- when 0x9A; array_enc << 0x0161 # 0xc5 0xa1
92
- when 0x9B; array_enc << 0x203A # 0xe2 0x80 0xba
93
- when 0x9C; array_enc << 0x0152 # 0xc5 0x93
94
- when 0x9E; array_enc << 0x017E # 0xc5 0xbe
95
- when 0x9F; array_enc << 0x0178 # 0xc5 0xb8
96
- else
97
- array_enc << num
98
- end
99
- end
100
- array_enc.pack('U*')
101
- end
102
- end
103
- end
@@ -1,35 +0,0 @@
1
- module REXML
2
- module Encoding
3
- begin
4
- require 'uconv'
5
-
6
- def decode_eucjp(str)
7
- Uconv::euctou8(str)
8
- end
9
-
10
- def encode_eucjp content
11
- Uconv::u8toeuc(content)
12
- end
13
- rescue LoadError
14
- require 'nkf'
15
-
16
- EUCTOU8 = '-Ewm0'
17
- U8TOEUC = '-Wem0'
18
-
19
- def decode_eucjp(str)
20
- NKF.nkf(EUCTOU8, str)
21
- end
22
-
23
- def encode_eucjp content
24
- NKF.nkf(U8TOEUC, content)
25
- end
26
- end
27
-
28
- register("EUC-JP") do |obj|
29
- class << obj
30
- alias decode decode_eucjp
31
- alias encode encode_eucjp
32
- end
33
- end
34
- end
35
- end
@@ -1,22 +0,0 @@
1
- require "iconv"
2
- raise LoadError unless defined? Iconv
3
-
4
- module REXML
5
- module Encoding
6
- def decode_iconv(str)
7
- Iconv.conv(UTF_8, @encoding, str)
8
- end
9
-
10
- def encode_iconv(content)
11
- Iconv.conv(@encoding, UTF_8, content)
12
- end
13
-
14
- register("ICONV") do |obj|
15
- Iconv.conv(UTF_8, obj.encoding, nil)
16
- class << obj
17
- alias decode decode_iconv
18
- alias encode encode_iconv
19
- end
20
- end
21
- end
22
- end
@@ -1,7 +0,0 @@
1
- require 'rexml/encodings/US-ASCII'
2
-
3
- module REXML
4
- module Encoding
5
- register("ISO-8859-1", &encoding_method("US-ASCII"))
6
- end
7
- end
@@ -1,72 +0,0 @@
1
- #
2
- # This class was contributed by Mikko Tiihonen mikko DOT tiihonen AT hut DOT fi
3
- #
4
- module REXML
5
- module Encoding
6
- register("ISO-8859-15") do |o|
7
- alias encode to_iso_8859_15
8
- alias decode from_iso_8859_15
9
- end
10
-
11
- # Convert from UTF-8
12
- def to_iso_8859_15(content)
13
- array_utf8 = content.unpack('U*')
14
- array_enc = []
15
- array_utf8.each do |num|
16
- case num
17
- # shortcut first bunch basic characters
18
- when 0..0xA3; array_enc << num
19
- # characters removed compared to iso-8859-1
20
- when 0xA4; array_enc << '&#164;'
21
- when 0xA6; array_enc << '&#166;'
22
- when 0xA8; array_enc << '&#168;'
23
- when 0xB4; array_enc << '&#180;'
24
- when 0xB8; array_enc << '&#184;'
25
- when 0xBC; array_enc << '&#188;'
26
- when 0xBD; array_enc << '&#189;'
27
- when 0xBE; array_enc << '&#190;'
28
- # characters added compared to iso-8859-1
29
- when 0x20AC; array_enc << 0xA4 # 0xe2 0x82 0xac
30
- when 0x0160; array_enc << 0xA6 # 0xc5 0xa0
31
- when 0x0161; array_enc << 0xA8 # 0xc5 0xa1
32
- when 0x017D; array_enc << 0xB4 # 0xc5 0xbd
33
- when 0x017E; array_enc << 0xB8 # 0xc5 0xbe
34
- when 0x0152; array_enc << 0xBC # 0xc5 0x92
35
- when 0x0153; array_enc << 0xBD # 0xc5 0x93
36
- when 0x0178; array_enc << 0xBE # 0xc5 0xb8
37
- else
38
- # all remaining basic characters can be used directly
39
- if num <= 0xFF
40
- array_enc << num
41
- else
42
- # Numeric entity (&#nnnn;); shard by Stefan Scholl
43
- array_enc.concat "&\##{num};".unpack('C*')
44
- end
45
- end
46
- end
47
- array_enc.pack('C*')
48
- end
49
-
50
- # Convert to UTF-8
51
- def from_iso_8859_15(str)
52
- array_latin9 = str.unpack('C*')
53
- array_enc = []
54
- array_latin9.each do |num|
55
- case num
56
- # characters that differ compared to iso-8859-1
57
- when 0xA4; array_enc << 0x20AC
58
- when 0xA6; array_enc << 0x0160
59
- when 0xA8; array_enc << 0x0161
60
- when 0xB4; array_enc << 0x017D
61
- when 0xB8; array_enc << 0x017E
62
- when 0xBC; array_enc << 0x0152
63
- when 0xBD; array_enc << 0x0153
64
- when 0xBE; array_enc << 0x0178
65
- else
66
- array_enc << num
67
- end
68
- end
69
- array_enc.pack('U*')
70
- end
71
- end
72
- end
@@ -1,37 +0,0 @@
1
- module REXML
2
- module Encoding
3
- begin
4
- require 'uconv'
5
-
6
- def decode_sjis content
7
- Uconv::sjistou8(content)
8
- end
9
-
10
- def encode_sjis(str)
11
- Uconv::u8tosjis(str)
12
- end
13
- rescue LoadError
14
- require 'nkf'
15
-
16
- SJISTOU8 = '-Swm0x'
17
- U8TOSJIS = '-Wsm0x'
18
-
19
- def decode_sjis(str)
20
- NKF.nkf(SJISTOU8, str)
21
- end
22
-
23
- def encode_sjis content
24
- NKF.nkf(U8TOSJIS, content)
25
- end
26
- end
27
-
28
- b = proc do |obj|
29
- class << obj
30
- alias decode decode_sjis
31
- alias encode encode_sjis
32
- end
33
- end
34
- register("SHIFT-JIS", &b)
35
- register("SHIFT_JIS", &b)
36
- end
37
- end
@@ -1 +0,0 @@
1
- require 'rexml/encodings/SHIFT-JIS'
@@ -1,34 +0,0 @@
1
- module REXML
2
- module Encoding
3
- def encode_unile content
4
- array_utf8 = content.unpack("U*")
5
- array_enc = []
6
- array_utf8.each do |num|
7
- if ((num>>16) > 0)
8
- array_enc << ??
9
- array_enc << 0
10
- else
11
- array_enc << (num & 0xFF)
12
- array_enc << (num >> 8)
13
- end
14
- end
15
- array_enc.pack('C*')
16
- end
17
-
18
- def decode_unile(str)
19
- array_enc=str.unpack('C*')
20
- array_utf8 = []
21
- 0.step(array_enc.size-1, 2){|i|
22
- array_utf8 << (array_enc.at(i) + array_enc.at(i+1)*0x100)
23
- }
24
- array_utf8.pack('U*')
25
- end
26
-
27
- register(UNILE) do |obj|
28
- class << obj
29
- alias decode decode_unile
30
- alias encode encode_unile
31
- end
32
- end
33
- end
34
- end
@@ -1,30 +0,0 @@
1
- module REXML
2
- module Encoding
3
- # Convert from UTF-8
4
- def encode_ascii content
5
- array_utf8 = content.unpack('U*')
6
- array_enc = []
7
- array_utf8.each do |num|
8
- if num <= 0x7F
9
- array_enc << num
10
- else
11
- # Numeric entity (&#nnnn;); shard by Stefan Scholl
12
- array_enc.concat "&\##{num};".unpack('C*')
13
- end
14
- end
15
- array_enc.pack('C*')
16
- end
17
-
18
- # Convert to UTF-8
19
- def decode_ascii(str)
20
- str.unpack('C*').pack('U*')
21
- end
22
-
23
- register("US-ASCII") do |obj|
24
- class << obj
25
- alias decode decode_ascii
26
- alias encode encode_ascii
27
- end
28
- end
29
- end
30
- end
@@ -1,35 +0,0 @@
1
- module REXML
2
- module Encoding
3
- def encode_utf16 content
4
- array_utf8 = content.unpack("U*")
5
- array_enc = []
6
- array_utf8.each do |num|
7
- if ((num>>16) > 0)
8
- array_enc << 0
9
- array_enc << ??
10
- else
11
- array_enc << (num >> 8)
12
- array_enc << (num & 0xFF)
13
- end
14
- end
15
- array_enc.pack('C*')
16
- end
17
-
18
- def decode_utf16(str)
19
- str = str[2..-1] if /^\376\377/n =~ str
20
- array_enc=str.unpack('C*')
21
- array_utf8 = []
22
- 0.step(array_enc.size-1, 2){|i|
23
- array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
24
- }
25
- array_utf8.pack('U*')
26
- end
27
-
28
- register(UTF_16) do |obj|
29
- class << obj
30
- alias decode decode_utf16
31
- alias encode encode_utf16
32
- end
33
- end
34
- end
35
- end
@@ -1,18 +0,0 @@
1
- module REXML
2
- module Encoding
3
- def encode_utf8 content
4
- content
5
- end
6
-
7
- def decode_utf8(str)
8
- str
9
- end
10
-
11
- register(UTF_8) do |obj|
12
- class << obj
13
- alias decode decode_utf8
14
- alias encode encode_utf8
15
- end
16
- end
17
- end
18
- end