rexpat 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.clang-format +1 -0
- data/.dir-locals.el +8 -0
- data/.document +5 -0
- data/.envrc +14 -0
- data/.rdoc_options +29 -0
- data/CHANGELOG.md +311 -0
- data/README.md +108 -0
- data/Rakefile +26 -0
- data/compile_flags.txt +7 -0
- data/ext/rexpat/extconf.rb +16 -0
- data/ext/rexpat/rexpat.c +864 -0
- data/ext/rexpat/rexpat.h +8 -0
- data/lib/rexpat/version.rb +7 -0
- data/lib/rexpat.rb +539 -0
- data/licenses/Expat-license.txt +21 -0
- data/licenses/Ruby-license.txt +56 -0
- data/sig/rexpat.rbs +50 -0
- metadata +64 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 89bb8c576fc92c48e465e739e5c13934c2bfb8a7840afd687230d4608aca7b1f
|
|
4
|
+
data.tar.gz: 4c882102c28fe5d1e93df3534ba83130d49803bef60aabfef3a36265526f4206
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a6c443a7ad41bfbde65b83f42f3303aaa8b295e31954f2e3560d33eae418532c8dc3c711138ed31cbb504cdd20d9488c4fb93b42269b3cdb1b9cb3379cd3e5fb
|
|
7
|
+
data.tar.gz: a619c4c035dd236f334e739b00d65875f727b66703e8d11a39ec644710898cdbdabc77dfc2df095c4d8be3e3a1c0f1ffe4bbdd86d65c851be2c81aefeb15c333
|
data/.clang-format
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
BasedOnStyle: GNU
|
data/.dir-locals.el
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
;;; Directory Local Variables -*- no-byte-compile: t -*-
|
|
2
|
+
;;; For more information see (info "(emacs) Directory Variables")
|
|
3
|
+
|
|
4
|
+
((nil . ((eval . (progn
|
|
5
|
+
(require 'grep)
|
|
6
|
+
(add-to-list 'grep-find-ignored-directories ".direnv")
|
|
7
|
+
(add-to-list 'grep-find-ignored-directories "tmp")
|
|
8
|
+
(add-to-list 'grep-find-ignored-directories "doc"))))))
|
data/.envrc
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
layout ruby
|
|
2
|
+
bundle install
|
|
3
|
+
export INSTALL="/usr/bin/install -c"
|
|
4
|
+
export LANG=en_US.UTF-8
|
|
5
|
+
path_add PERL5LIB "$HOME/src/po4a/lib"
|
|
6
|
+
PATH_add "$HOME/src/po4a"
|
|
7
|
+
layout perl
|
|
8
|
+
PATH_add "$HOME/perl5/bin"
|
|
9
|
+
path_add C_INCLUDE_PATH /usr/local/include
|
|
10
|
+
cpanm YAML::Tiny Syntax::Keyword::Try CommonMark
|
|
11
|
+
export MAKEFLAGS=e
|
|
12
|
+
path_add C_INCLUDE_PATH /usr/local/include/ruby-4.0
|
|
13
|
+
path_add C_INCLUDE_PATH /usr/local/include/ruby-4.0/x86_64-openbsd
|
|
14
|
+
path_add C_INCLUDE_PATH /usr/local/llvm21/lib/clang/21/include
|
data/.rdoc_options
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
encoding: UTF-8
|
|
3
|
+
static_path: []
|
|
4
|
+
rdoc_include: []
|
|
5
|
+
page_dir:
|
|
6
|
+
apply_default_exclude: true
|
|
7
|
+
autolink_excluded_words: []
|
|
8
|
+
canonical_root:
|
|
9
|
+
charset: UTF-8
|
|
10
|
+
class_module_path_prefix:
|
|
11
|
+
embed_mixins: false
|
|
12
|
+
exclude: []
|
|
13
|
+
file_path_prefix:
|
|
14
|
+
footer_content:
|
|
15
|
+
hyperlink_all: false
|
|
16
|
+
line_numbers: false
|
|
17
|
+
locale_dir: locale
|
|
18
|
+
locale_name:
|
|
19
|
+
main_page: README.md
|
|
20
|
+
markup: rdoc
|
|
21
|
+
output_decoration: true
|
|
22
|
+
show_hash: false
|
|
23
|
+
skip_tests: true
|
|
24
|
+
tab_width: 8
|
|
25
|
+
template_stylesheets: []
|
|
26
|
+
title:
|
|
27
|
+
visibility: :protected
|
|
28
|
+
warn_missing_rdoc_ref: true
|
|
29
|
+
webcvs:
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Change Log for RExpat gem
|
|
2
|
+
|
|
3
|
+
The entries with the prefix "ja:" is in Japanese.
|
|
4
|
+
The entries with the prefix "C: " means it was written only in
|
|
5
|
+
`ext/rexpat/rexpat.c` in the past.
|
|
6
|
+
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
## 0.8.0 - 2026-11-04
|
|
10
|
+
|
|
11
|
+
* This is a major rework, so almost all APIs have changed.
|
|
12
|
+
|
|
13
|
+
## 0.7.3 - Feb 7, 2013
|
|
14
|
+
|
|
15
|
+
* fixes PARAM_ENTITY_PARSING_* constants
|
|
16
|
+
* ja: PARAM_ENTITY_PARSING_* 定数を修正
|
|
17
|
+
|
|
18
|
+
Note: This and prior to this version was made by yoshidam.
|
|
19
|
+
|
|
20
|
+
## 0.7.2 - Feb 28, 2011
|
|
21
|
+
|
|
22
|
+
* reverts once removed digest.rb
|
|
23
|
+
* ja: digest.rb を再収録
|
|
24
|
+
|
|
25
|
+
## 0.7.1 - Dec 28, 2009
|
|
26
|
+
|
|
27
|
+
* Ruby 1.9.1 encoding conversion
|
|
28
|
+
* ja: Ruby 1.9.1 エンコーディング変換対応
|
|
29
|
+
|
|
30
|
+
## 0.7.0 - Dec 15, 2009
|
|
31
|
+
|
|
32
|
+
* Ruby 1.9.1
|
|
33
|
+
* ja: Ruby 1.9.1 対応
|
|
34
|
+
|
|
35
|
+
## 0.6.8 - Apr 5, 2004 (or Feb 16, 2004)
|
|
36
|
+
|
|
37
|
+
* fixes overflow, and taints output string.
|
|
38
|
+
|
|
39
|
+
## 0.6.7 - Feb 16, 2004
|
|
40
|
+
|
|
41
|
+
* C: fix buffer overflow
|
|
42
|
+
|
|
43
|
+
## 0.6.6 - Mar 11, 2003
|
|
44
|
+
|
|
45
|
+
* ja: 外部実体パーサ生成時のskippedEntityハンドラの初期化忘れを修正
|
|
46
|
+
|
|
47
|
+
## 0.6.5 - Sep 20, 2002
|
|
48
|
+
|
|
49
|
+
* fixes reset method
|
|
50
|
+
* adds skippedEntity event for expat-1.95.4
|
|
51
|
+
* adds XML::Parser.getFeatureList and XML::Parser#useForeignDTD for expat-1.95.5
|
|
52
|
+
|
|
53
|
+
## 0.6.4 - Jun 18, 2002
|
|
54
|
+
|
|
55
|
+
* adds XML::Parser#reset for expat-1.95.3.
|
|
56
|
+
* ja: expat-1.95.3 用に XML::Parser#reset 追加
|
|
57
|
+
|
|
58
|
+
## 0.6.3 - Apr 4, 2002
|
|
59
|
+
|
|
60
|
+
* C: change event code values
|
|
61
|
+
|
|
62
|
+
## 0.6.2 - Mar 23, 2002
|
|
63
|
+
|
|
64
|
+
* changes a layout under lib
|
|
65
|
+
* changes the parent class of XML::Parser::Error
|
|
66
|
+
* adds an experimental implementaion of DOM Level 2
|
|
67
|
+
* adds XML::ParserNS (experimental)
|
|
68
|
+
* ja: lib のレイアウト変更
|
|
69
|
+
* ja: XML::Parser::Error の親クラス変更
|
|
70
|
+
* ja: DOM Level 2 の実験的対応
|
|
71
|
+
* ja: 名前空間の実験的対応 (XML::ParserNS)
|
|
72
|
+
|
|
73
|
+
## 0.6.1 - Oct 15, 2000 (or Oct 10, 2000)
|
|
74
|
+
|
|
75
|
+
* support expat-1.95.0 and expat-1.2
|
|
76
|
+
* ja: expat-1.95.0,expat-1.2 対応
|
|
77
|
+
|
|
78
|
+
## 0.6.0 - Oct 6, 2000
|
|
79
|
+
|
|
80
|
+
* C: support expat-1.95.0
|
|
81
|
+
|
|
82
|
+
## 0.5.19 - Aug 5, 2000
|
|
83
|
+
|
|
84
|
+
* RDize xmltree.rb by TAKAHASHI Masayoshi
|
|
85
|
+
* ja: 高橋征義さんが xmltree.rb 等を RD 化してくださいました。
|
|
86
|
+
|
|
87
|
+
## 0.5.18 - Jun 28, 1999 (or May 30, 2000)
|
|
88
|
+
|
|
89
|
+
* fix for Ruby 1.5
|
|
90
|
+
* ja: ruby 1.5 で動かなくなっていたので修正
|
|
91
|
+
* C: define initialize for Ruby 1.5
|
|
92
|
+
|
|
93
|
+
## 0.5.17 - Jan 4, 2000
|
|
94
|
+
|
|
95
|
+
* ja: NodeList#+ の問題修正 (Masatoshi SEKIさんありがとうございます)
|
|
96
|
+
|
|
97
|
+
## 0.5.16 - Oct 14, 1999
|
|
98
|
+
|
|
99
|
+
* change some samples
|
|
100
|
+
* ja: いくつかのサンプルプログラムを変更
|
|
101
|
+
|
|
102
|
+
## 0.5.15 - Aug 18, 1999 (or Jun 28, 1999)
|
|
103
|
+
|
|
104
|
+
* support start/endDoctypeDecl event of expat-19990728.
|
|
105
|
+
* fix SAX driver bug.
|
|
106
|
+
* ja: expat-19990728 の start/endDoctypeDecl に対応
|
|
107
|
+
* ja: SAX ドライバのバグ修正
|
|
108
|
+
|
|
109
|
+
## 0.5.14 - Jun 29, 1999 (or Jun 28, 1999)
|
|
110
|
+
|
|
111
|
+
* support to parse external parameter entities for expat-19990626
|
|
112
|
+
* ja: expat-19990626 の外部パラメータ実体(および外部 DTD サブセット)の読み込みに対応
|
|
113
|
+
* ja: Ruby-1.2 サポートを中止。
|
|
114
|
+
* C: support setParamEntityParsing
|
|
115
|
+
|
|
116
|
+
## 0.5.13 - Jun 10, 1999
|
|
117
|
+
|
|
118
|
+
* support experimental SAX driver support expat-1.1
|
|
119
|
+
* ja: 実験的 SAX ドライバを追加
|
|
120
|
+
* expat-1.1 対応
|
|
121
|
+
|
|
122
|
+
## 0.5.12 - May 13, 1999
|
|
123
|
+
|
|
124
|
+
* fix extconf.rb bug
|
|
125
|
+
* ja: extconf.rb のバグ修正 (藤本尚邦さんありがとうございます)
|
|
126
|
+
|
|
127
|
+
## 0.5.11 - Apr 28, 1999
|
|
128
|
+
|
|
129
|
+
* for expat-19990425, add NotStandalone event, getSpecifiedAttributes method and byteCount method
|
|
130
|
+
* ja: expat-19990425 に対応し, NotStandaloneイベント,getSpecifiedAttributes, byteCount メソッド追加
|
|
131
|
+
|
|
132
|
+
## 0.5.10 - Apr 20, 1999
|
|
133
|
+
|
|
134
|
+
* change xmldigest.rb for xss4j
|
|
135
|
+
* ja: xss4j を参考にして xmldigest.rb を変更
|
|
136
|
+
|
|
137
|
+
## 0.5.9 - Mar 29, 1998
|
|
138
|
+
|
|
139
|
+
* change the object structure for Ruby 1.3
|
|
140
|
+
* ja: Ruby 1.3 用にオブジェクトの構造を変更
|
|
141
|
+
* C: optimize for Ruby 1.3
|
|
142
|
+
|
|
143
|
+
## 0.5.8 - Mar 23, 1999
|
|
144
|
+
|
|
145
|
+
* support the omission of keywords of XPointer
|
|
146
|
+
* support to parse external parsed entities in XML::DOM::Builder
|
|
147
|
+
* ja: XPointer のキーワードの省略を可能にした
|
|
148
|
+
* ja: XML::DOM::Builder で外部パース実体の処理を追加
|
|
149
|
+
|
|
150
|
+
## 0.5.7 - Mar 8, 1998
|
|
151
|
+
|
|
152
|
+
* support start/endNamespaceDecl event of expat-19990307.
|
|
153
|
+
* ja: expat-19990307 の start/endNamespaceDeclイベントに対応
|
|
154
|
+
|
|
155
|
+
## 0.5.6 - Jan 25, 1999
|
|
156
|
+
|
|
157
|
+
* class name aliases are defined in C module.
|
|
158
|
+
* support cygwin.
|
|
159
|
+
* ja: クラス名の別名を C モジュール内に移動
|
|
160
|
+
* ja: Cygwin で動作させるための変更
|
|
161
|
+
|
|
162
|
+
## 0.5.5 - Jan 14, 1999
|
|
163
|
+
|
|
164
|
+
* support start/endCdataSection event of expat-19981231
|
|
165
|
+
* ja: expat-19981231 の start/endCdataSectionイベントに対応
|
|
166
|
+
* ja: xmltreebuilder をテスト版 expatに対応させた (comment, CDATA)
|
|
167
|
+
* ja: Node#trim を CDATA セクションも trimするように改造
|
|
168
|
+
|
|
169
|
+
## 0.5.4 - Jan 14, 1998 (or Jan 13, 1999)
|
|
170
|
+
|
|
171
|
+
* modify xmltree and xmltreebuilder
|
|
172
|
+
* ja: xmltree, xmltreebuilder 改造 (バグが入ったかも)
|
|
173
|
+
* C: support start/endCdataSection
|
|
174
|
+
|
|
175
|
+
## 0.5.3 - Jan 10, 1998
|
|
176
|
+
|
|
177
|
+
* encoding map support
|
|
178
|
+
* ja: Perl 用 encoding map 対応
|
|
179
|
+
|
|
180
|
+
## 0.5.2 - Jan 1, 1999
|
|
181
|
+
|
|
182
|
+
* ja: expat-19981231 対応
|
|
183
|
+
|
|
184
|
+
## 0.5.1 - Dec 1, 1998
|
|
185
|
+
|
|
186
|
+
* fix some bugs
|
|
187
|
+
* ja: 問題点修正(福嶋正機さんありがとうございます)
|
|
188
|
+
|
|
189
|
+
## 0.5.0 - Nov 24, 1998
|
|
190
|
+
|
|
191
|
+
* support the test version of expat
|
|
192
|
+
* ja: テスト版 expat 対応
|
|
193
|
+
|
|
194
|
+
## 0.4.18 - Nov 5, 1998
|
|
195
|
+
|
|
196
|
+
* fix some bugs, class name alias:
|
|
197
|
+
XMLParserErorr -> XML::Parser::Error,
|
|
198
|
+
and change some internal functions.
|
|
199
|
+
* ja: バグ修正(福嶋正機さんありがとうございます)
|
|
200
|
+
* ja: クラス名に別名定義:
|
|
201
|
+
XMLParserError -> XML::Parser::Error
|
|
202
|
+
* ja: メソッド ID の初期化位置変更
|
|
203
|
+
* ja: xmltreebuilder で Ruby のバグ?回避
|
|
204
|
+
* C: mIDs are initialized in Init_xmlparser
|
|
205
|
+
|
|
206
|
+
## 0.4.17 - Oct 28, 1998
|
|
207
|
+
|
|
208
|
+
* mIDs are stored into static vars
|
|
209
|
+
* ja: メソッド ID を静的変数に移した
|
|
210
|
+
|
|
211
|
+
## 0.4.16 - Oct 28, 1998
|
|
212
|
+
|
|
213
|
+
* change ID attribute support of XPointer.
|
|
214
|
+
* Node#trim is now xml:space-aware
|
|
215
|
+
* ja: XPointer 使用時の ID 属性を外部から指定可能にした
|
|
216
|
+
* ja: Node#trim を xml:space 対応にした
|
|
217
|
+
|
|
218
|
+
## 0.4.15 - Oct 23, 1998
|
|
219
|
+
|
|
220
|
+
* fix some bugs, add class name alias:
|
|
221
|
+
XMLParser -> XML::Parser,
|
|
222
|
+
XML::SimpleTree -> XML::DOM,
|
|
223
|
+
XML::SimpleTreeBuilder -> XML::DOM::Builder
|
|
224
|
+
* ja: バグ修正,クラス名に別名定義:
|
|
225
|
+
XMLParser -> XML::Parser,
|
|
226
|
+
XML::SimpleTree -> XML::DOM,
|
|
227
|
+
XML::SimpleTreeBuilder -> XML::DOM::Builder
|
|
228
|
+
|
|
229
|
+
## 0.4.14 - Oct 20, 1998
|
|
230
|
+
|
|
231
|
+
* add better XPointer support by Masaki Fukushima
|
|
232
|
+
* ja: 福嶋正機さんによる XPointer サポートを追加
|
|
233
|
+
|
|
234
|
+
## 0.4.13 - Oct 18, 1998
|
|
235
|
+
|
|
236
|
+
* ja: SimpleTree のバグ修正,Visitor 追加
|
|
237
|
+
|
|
238
|
+
## 0.4.12 - Oct 13, 1998
|
|
239
|
+
|
|
240
|
+
* ja: バグ修正,エンコーディング変換部の高速化
|
|
241
|
+
* C: debug and speed up myEncodingConv
|
|
242
|
+
|
|
243
|
+
## 0.4.11 - Oct 7, 1998
|
|
244
|
+
|
|
245
|
+
* ja: パーサ内部のオブジェクト管理の変更
|
|
246
|
+
* C: hold internal object into ivar
|
|
247
|
+
|
|
248
|
+
## 0.4.9 - Oct 4, 1998
|
|
249
|
+
|
|
250
|
+
* ja: 細かいバグ修正,DOM 勧告対応など
|
|
251
|
+
|
|
252
|
+
## 0.4.8 - Sep 22, 1998
|
|
253
|
+
|
|
254
|
+
* ja: ストリームの仕様を少し変更
|
|
255
|
+
|
|
256
|
+
## 0.4.7 - Sep 21, 1998
|
|
257
|
+
|
|
258
|
+
* ja: SimpleTree, SimpleTreeBuilder に Comment など追加
|
|
259
|
+
|
|
260
|
+
## 0.4.6 - Sep 18, 1998
|
|
261
|
+
|
|
262
|
+
* ja: UnknownEncoding イベントに対応
|
|
263
|
+
|
|
264
|
+
## 0.4.5 - Sep 17, 1998
|
|
265
|
+
|
|
266
|
+
* add methods to SimpleTree
|
|
267
|
+
* ja: SimpleTree にメソッド追加
|
|
268
|
+
|
|
269
|
+
## 0.4.4 - Sep 8, 1998
|
|
270
|
+
|
|
271
|
+
* change parser object type from T_DATA to T_OBJECT (now can use instance variables)
|
|
272
|
+
* ja: パーサオブジェクトが T_DATA からT_OBJECT に変更
|
|
273
|
+
|
|
274
|
+
## 0.4.3 - Sep 3, 1998
|
|
275
|
+
|
|
276
|
+
* add isFinal flag, and stream parsing facility
|
|
277
|
+
* ja: isFinal フラグを追加,ストリーム対応
|
|
278
|
+
|
|
279
|
+
## 0.4.2 - Sep 2, 1998 (or Sep 1, 1998)
|
|
280
|
+
|
|
281
|
+
* add external entity event and parser
|
|
282
|
+
* ja: 外部実体イベント,外部実体パーサ追加
|
|
283
|
+
|
|
284
|
+
## 0.4.1 - Aug 28, 1998
|
|
285
|
+
|
|
286
|
+
## 0.4.0 - Aug 22, 1998
|
|
287
|
+
|
|
288
|
+
## 0.3.3 - Aug 14, 1998
|
|
289
|
+
|
|
290
|
+
* support expat 1.0
|
|
291
|
+
* ja: expat 1.0 対応
|
|
292
|
+
|
|
293
|
+
## 0.3.2 - Aug 12, 1998
|
|
294
|
+
|
|
295
|
+
* ja: SimpleTree に XPointer もどきを追加 (root, child ,id のみサポート)
|
|
296
|
+
|
|
297
|
+
## 0.3.1 - Aug 4, 1998
|
|
298
|
+
|
|
299
|
+
* ja: ライブラリ追加,expat_ja 動作確認
|
|
300
|
+
|
|
301
|
+
## 0.3 - Jul 17, 1998
|
|
302
|
+
|
|
303
|
+
* ja: イテレータブロック内のdefaultCurrent に対応
|
|
304
|
+
|
|
305
|
+
## 0.2 - Jul 6, 1998 (or Jul 3, 1998)
|
|
306
|
+
|
|
307
|
+
* ja: イテレータに対応
|
|
308
|
+
|
|
309
|
+
## 0.1 - Jul 1, 1998 (or Jun 30, 1998)
|
|
310
|
+
|
|
311
|
+
* ja: リリース
|
data/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# RExpat - Ruby Extension module for the Expat
|
|
2
|
+
|
|
3
|
+
This RubyGem is a Ruby extension module to access the
|
|
4
|
+
[Expat](https://libexpat.github.io/) (XML Parser Toolkit; [James
|
|
5
|
+
Clark's home page](http://www.jclark.com/xml/expat.html)), written by
|
|
6
|
+
James Clark.
|
|
7
|
+
|
|
8
|
+
This is a fork of the [xmlparser
|
|
9
|
+
gem](https://rubygems.org/gems/xmlparser) created by 吉田正人 (Yoshida
|
|
10
|
+
Masato), in the aim of supporting newer Expat and Ruby versions and
|
|
11
|
+
polishing the API design. The goal is not to be a drop-in replacement
|
|
12
|
+
of the gem, but a lean wrapper implementation.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Prerequisites:
|
|
17
|
+
|
|
18
|
+
* Expat 1.95.5 or later, but we recommend to use the
|
|
19
|
+
latest release due to the security reasons.
|
|
20
|
+
* Relatively newer CRuby. We recommend CRuby 3.2 or later.
|
|
21
|
+
|
|
22
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bundle add rexpat
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If bundler is not being used to manage dependencies, install the gem
|
|
29
|
+
by executing:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
gem install rexpat
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This gem uses the mkmf gem, so you can provide some options for Expat
|
|
36
|
+
locations:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
gem install rexpat -- \
|
|
40
|
+
--with-expat-include=/path/to/expat/include \
|
|
41
|
+
--with-expat-lib=/path/to/expat/lib
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
To load the library:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'rexpat'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To get the parse results, you have to define various event handlers.
|
|
53
|
+
The approach is like Simple API for XML (SAX) style. You can make a
|
|
54
|
+
subclass of the `RExpat` class and define event handler methods in it,
|
|
55
|
+
or define singleton methods for instances of the `RExpat` class. If
|
|
56
|
+
no event handlers defined, it only checks the grammer. For example:
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
class MyParser < RExpat
|
|
60
|
+
def on_start_element(name, attrs)
|
|
61
|
+
puts "name is #{name}" \
|
|
62
|
+
"and attributes are #{attrs.inspect}"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
parser = MyParser.new
|
|
67
|
+
|
|
68
|
+
# # or
|
|
69
|
+
# parser = RExpat.new
|
|
70
|
+
# parser.define_singleton_method(:on_start_element) do |name, attrs|
|
|
71
|
+
# puts "name is #{name}" \
|
|
72
|
+
# "and attributes are #{attrs.inspect}"
|
|
73
|
+
# end
|
|
74
|
+
|
|
75
|
+
parser.parse('<root foo="bar"/>')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This gem supports UTF-8 and UTF-16 as input character encodings. The
|
|
79
|
+
output is in UTF-8.
|
|
80
|
+
|
|
81
|
+
See also the API documentation.
|
|
82
|
+
|
|
83
|
+
## Differences with the xmlparser gem
|
|
84
|
+
|
|
85
|
+
This gem dropped the support for custom encodings. If you are
|
|
86
|
+
interested in it, we welcome patches. Please also refer to the
|
|
87
|
+
official article, ["Writing A Custom
|
|
88
|
+
Encoding"](https://libexpat.github.io/doc/writing-a-custom-encoding/).
|
|
89
|
+
Note that providing a flexible Ruby interface to customize the
|
|
90
|
+
encoding mapping on "unknown encoding" events has been considerably
|
|
91
|
+
inefficient and easily become errorprone.
|
|
92
|
+
|
|
93
|
+
This gem dropped the support for iterator APIs. It might be
|
|
94
|
+
implemented in the future, but in pure Ruby (rather than in C) on top
|
|
95
|
+
of the current bindings.
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
Bug reports and pull requests are welcome.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
Copyright (C) 2013 吉田正人
|
|
104
|
+
Copyright (C) 2026 gemmaro
|
|
105
|
+
|
|
106
|
+
It is licensed under the Ruby license (see
|
|
107
|
+
`licenses/Ruby-license.txt`) or the Expat license (that is, MIT
|
|
108
|
+
license; see `licenses/Expat-license.txt`).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << "test"
|
|
8
|
+
t.libs << "lib"
|
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
require "rake/extensiontask"
|
|
13
|
+
|
|
14
|
+
task build: [:compile]
|
|
15
|
+
|
|
16
|
+
GEMSPEC = Gem::Specification.load("rexpat.gemspec")
|
|
17
|
+
|
|
18
|
+
Rake::ExtensionTask.new("rexpat", GEMSPEC) do |ext|
|
|
19
|
+
ext.lib_dir = "lib/rexpat"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
task default: %i[clobber compile test]
|
|
23
|
+
|
|
24
|
+
task :rdoc do
|
|
25
|
+
sh 'rdoc'
|
|
26
|
+
end
|
data/compile_flags.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This work is licensed under the Ruby license or the Expat license.
|
|
2
|
+
|
|
3
|
+
require 'mkmf'
|
|
4
|
+
|
|
5
|
+
dir_config("expat")
|
|
6
|
+
|
|
7
|
+
have_header("expat.h") or raise "no Expat header"
|
|
8
|
+
have_library("expat", "XML_ParserCreate") \
|
|
9
|
+
or raise "no Expat library with the function XML_ParserCreate"
|
|
10
|
+
|
|
11
|
+
if with_config('debug')
|
|
12
|
+
$defs.push('-DRBE_DEBUG') unless $defs.include?('-DRBE_DEBUG')
|
|
13
|
+
append_cflags(['-g', '-O0'])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
create_makefile("rexpat")
|