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
data/ext/rexpat/rexpat.h
ADDED
data/lib/rexpat.rb
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# This work is licensed under the Ruby license or the Expat license.
|
|
4
|
+
|
|
5
|
+
require_relative "rexpat/version"
|
|
6
|
+
require "rexpat/rexpat"
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# This is a main parser class.
|
|
10
|
+
#
|
|
11
|
+
# The +on_+ methods are event handlers.
|
|
12
|
+
class RExpat
|
|
13
|
+
class << self
|
|
14
|
+
##
|
|
15
|
+
# :method: expat_version
|
|
16
|
+
#
|
|
17
|
+
# Get expat version.
|
|
18
|
+
#
|
|
19
|
+
# expat のバージョンを得ます。
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# :method: features
|
|
23
|
+
#
|
|
24
|
+
# Get a hash list of expat API's features.
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# :method: initialize
|
|
29
|
+
# :call-seq: new (encoding: nil, nssep: nil) -> RExpat
|
|
30
|
+
#
|
|
31
|
+
# +encoding+ can be specified to ISO-8859-1, UTF-8, US-ASCII and
|
|
32
|
+
# UTF-16, which Expat can recognize.
|
|
33
|
+
#
|
|
34
|
+
# +nssep+ enables namespace extension. The namespace-prefixed
|
|
35
|
+
# element and attribute names are concatenated with the namespace's
|
|
36
|
+
# URI and a separator (the first byte of +nssep+).
|
|
37
|
+
#
|
|
38
|
+
# For example, with <tt>nssep = '!'</tt>,
|
|
39
|
+
#
|
|
40
|
+
# <hoge:test xmlns:hoge="http://www.yoshidam.net/ns/hoge">
|
|
41
|
+
#
|
|
42
|
+
# is parsed into
|
|
43
|
+
#
|
|
44
|
+
# http://www.yoshidam.net/ns/hoge!test
|
|
45
|
+
#
|
|
46
|
+
# It can raise RExpat::Error.
|
|
47
|
+
#
|
|
48
|
+
# See also #reset for reusing the parser. Note that the xmlparser
|
|
49
|
+
# gem prohibits the reuse, I don't know why.
|
|
50
|
+
#
|
|
51
|
+
# 作成に失敗すると RExpat::Error 例外が発生します。 +encoding+ とし
|
|
52
|
+
# て文字エンコーディングを外部から指定することも出来ます。Expat が対
|
|
53
|
+
# 応しているエンコーディング名(ISO-8859-1, UTF-8, US-ASCII, UTF-16)
|
|
54
|
+
# が使えます。
|
|
55
|
+
#
|
|
56
|
+
# +nssep+ を指定すると名前空間拡張が有効になります。エレメントや属性
|
|
57
|
+
# の名前にプレフィックスを指定すると,エレメント名や属性名が URI と
|
|
58
|
+
# ローカルパートを連結した名前になります。 +nssep+ で指定された文字
|
|
59
|
+
# 列の最初の文字がセパレータになります。
|
|
60
|
+
#
|
|
61
|
+
# 例えば
|
|
62
|
+
#
|
|
63
|
+
# <hoge:test xmlns:hoge="http://www.yoshidam.net/ns/hoge">
|
|
64
|
+
#
|
|
65
|
+
# を <tt>nssep = '!'</tt> でパースすると,エレメント名は
|
|
66
|
+
#
|
|
67
|
+
# http://www.yoshidam.net/ns/hoge!test
|
|
68
|
+
#
|
|
69
|
+
# になります。
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# :method: external_entity_parser
|
|
73
|
+
# :call-seq: external_entity_parser (context: nil, encoding: nil) -> RExpat
|
|
74
|
+
#
|
|
75
|
+
# This creates an XML parser object that can parse an external
|
|
76
|
+
# entity. It can raise RExpat::Error.
|
|
77
|
+
#
|
|
78
|
+
# This can be called at any point after the first
|
|
79
|
+
# +#on_external_entity_ref+ event call.
|
|
80
|
+
#
|
|
81
|
+
# The +context+ parameter should be the parsing context given by the
|
|
82
|
+
# +#on_external_entity_ref+ event.
|
|
83
|
+
#
|
|
84
|
+
# The +encoding+ parameter is an optional character encoding.
|
|
85
|
+
#
|
|
86
|
+
# The returned parser can be reused by calling #reset.
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# :method: parse
|
|
90
|
+
# :call-seq: parse(str = nil, final: true)
|
|
91
|
+
#
|
|
92
|
+
# Parse a string. The parse results can be processed by event
|
|
93
|
+
# handlers.
|
|
94
|
+
#
|
|
95
|
+
# +final+ parameter must true on last call of this method. Default
|
|
96
|
+
# is true. No parameter call of this method indicates the end of
|
|
97
|
+
# parsing.
|
|
98
|
+
#
|
|
99
|
+
# A failure to parse raises a RExpat::Error exception.
|
|
100
|
+
#
|
|
101
|
+
# +str+ をパースします。パース結果としてイベントハンドラが呼び出され
|
|
102
|
+
# ます。
|
|
103
|
+
#
|
|
104
|
+
# +final+ は XML の途中までパースする場合は false, 最後までの場合は
|
|
105
|
+
# true を指定して下さい。省略時は true です。引数無しで呼び出すこと
|
|
106
|
+
# で,パースの終了を指示することもできます。
|
|
107
|
+
#
|
|
108
|
+
# パースエラーを検出すると RExpat::Error 例外が発生します。
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# :method: default_current
|
|
112
|
+
#
|
|
113
|
+
# Raise a +#on_default+ event within any event handlers. You can
|
|
114
|
+
# get the corresponding markup.
|
|
115
|
+
#
|
|
116
|
+
# If within a event handler, it raise a +#on_default+ event
|
|
117
|
+
# immediately.
|
|
118
|
+
#
|
|
119
|
+
# イベントハンドラ内で呼び出します。 +#on_default+ イベントを発生さ
|
|
120
|
+
# せ,パース前の生のデータを得ることができます。イベントハンドラ内で
|
|
121
|
+
# すぐさま +#on_default+ イベントが発生します。 +#on_default+ ハンド
|
|
122
|
+
# ラーは呼び出されないことに注意して下さい。
|
|
123
|
+
|
|
124
|
+
##
|
|
125
|
+
# :method: base=
|
|
126
|
+
# :call-seq: parser.base = base
|
|
127
|
+
#
|
|
128
|
+
# The value is assigned as the URL base for external entities. See
|
|
129
|
+
# also the +#on_external_entity_ref+ event handler.
|
|
130
|
+
#
|
|
131
|
+
# This can raise RExpat::Error when out of memory.
|
|
132
|
+
|
|
133
|
+
##
|
|
134
|
+
# :method: line
|
|
135
|
+
#
|
|
136
|
+
# Get current parsing location.
|
|
137
|
+
#
|
|
138
|
+
# When a #parse method raises RExpat::Error, these method return the
|
|
139
|
+
# position of the error detected.
|
|
140
|
+
#
|
|
141
|
+
# See also #column and #byte_index.
|
|
142
|
+
#
|
|
143
|
+
# イベントハンドラ内で呼び出します。現在のパース位置を返します。また,
|
|
144
|
+
# +#parse+ メソッドが RExpat::Error 例外で発生した時に呼び出すとエラー
|
|
145
|
+
# 位置を返します。
|
|
146
|
+
|
|
147
|
+
##
|
|
148
|
+
# :method: column
|
|
149
|
+
#
|
|
150
|
+
# Get current parsing location.
|
|
151
|
+
#
|
|
152
|
+
# When a #parse method raises RExpat::Error, these method return the
|
|
153
|
+
# position of the error detected.
|
|
154
|
+
#
|
|
155
|
+
# See also #line and #byte_index.
|
|
156
|
+
#
|
|
157
|
+
# イベントハンドラ内で呼び出します。現在のパース位置を返します。また,
|
|
158
|
+
# +#parse+ メソッドが RExpat::Error 例外で発生した時に呼び出すとエラー
|
|
159
|
+
# 位置を返します。
|
|
160
|
+
|
|
161
|
+
# :method: byte_index
|
|
162
|
+
#
|
|
163
|
+
# Get current parsing location.
|
|
164
|
+
#
|
|
165
|
+
# When #parse method raises RExpat::Error, these method return the
|
|
166
|
+
# position of the error detected.
|
|
167
|
+
#
|
|
168
|
+
# See also #line and #column.
|
|
169
|
+
#
|
|
170
|
+
# イベントハンドラ内で呼び出します。現在のパース位置を返します。また,
|
|
171
|
+
# +#parse+ メソッドが RExpat::Error 例外で発生した時に呼び出すとエラー
|
|
172
|
+
# 位置を返します。
|
|
173
|
+
|
|
174
|
+
##
|
|
175
|
+
# :method: byte_count
|
|
176
|
+
#
|
|
177
|
+
# Get the number of bytes in the current event. This should be
|
|
178
|
+
# called in event handlers.
|
|
179
|
+
#
|
|
180
|
+
# When the event is in an internal entity, this method returns 0.
|
|
181
|
+
#
|
|
182
|
+
# イベントハンドラ内で呼び出します。現在のイベント対象の
|
|
183
|
+
# 長さを返します。内部実体では 0 を返します。
|
|
184
|
+
|
|
185
|
+
##
|
|
186
|
+
# :method: specified_attributes
|
|
187
|
+
#
|
|
188
|
+
# This returns an array of specified attribute names. This method
|
|
189
|
+
# should be used in the +#on_start_element+ event handler.
|
|
190
|
+
|
|
191
|
+
##
|
|
192
|
+
# :method: param_entity_parsing=
|
|
193
|
+
# :call-seq: parser.param_entity_parsing = parsing
|
|
194
|
+
#
|
|
195
|
+
# Controls parsing of parameter entities, including the external DTD
|
|
196
|
+
# subset.
|
|
197
|
+
#
|
|
198
|
+
# +parsing+ parameter is either of +:never+, +:unless_standalone+,
|
|
199
|
+
# or +:always+.
|
|
200
|
+
#
|
|
201
|
+
# References to external parameter entities will invoke the
|
|
202
|
+
# +#on_external_entity_ref+ event. The +context+ will be nil.
|
|
203
|
+
#
|
|
204
|
+
# This can raise RExpat::Error.
|
|
205
|
+
#
|
|
206
|
+
# 外部パラメータ実体(外部 DTD サブセットも含む) をパースするかどうか
|
|
207
|
+
# を指定します。 +parsing+ には +:never+, +:unless_standalone+,
|
|
208
|
+
# +:always+のいずれかを指定してください。
|
|
209
|
+
#
|
|
210
|
+
# 外部パラメータエンティティをパースする場合,
|
|
211
|
+
# +#on_external_entity_ref+イベントが呼び出されます。 +context+ は
|
|
212
|
+
# nil になります。
|
|
213
|
+
|
|
214
|
+
##
|
|
215
|
+
# :method: return_ns_triplet=
|
|
216
|
+
# :call-seq: return_ns_triplet = do_nst
|
|
217
|
+
#
|
|
218
|
+
# Sets namespace triplet flag. It tells whether to use the URI, the
|
|
219
|
+
# local name, and the prefix if the namespace is enabled, or always
|
|
220
|
+
# use the URI and the local name if false.
|
|
221
|
+
#
|
|
222
|
+
# 名前空間が有効なときに,URI + ローカル名 + プレフィックスを使うか
|
|
223
|
+
# どうか指示します。 +false+ の時はURI + ローカル名です。
|
|
224
|
+
|
|
225
|
+
##
|
|
226
|
+
# :method: input_context
|
|
227
|
+
#
|
|
228
|
+
# Returns the parser's input buffer and current parse
|
|
229
|
+
# posion.
|
|
230
|
+
#
|
|
231
|
+
# 入力バッファと現在パース位置を得ます。
|
|
232
|
+
|
|
233
|
+
##
|
|
234
|
+
# :method: id_attribute
|
|
235
|
+
#
|
|
236
|
+
# Gets the ID attribute name.
|
|
237
|
+
#
|
|
238
|
+
# This method should be used in +#on_start_element+ event handler.
|
|
239
|
+
#
|
|
240
|
+
# Note that the ID attribute here is the one declared in the doctype
|
|
241
|
+
# declaration, rather than the one with an +xml:id+ attribute nor a
|
|
242
|
+
# plain +id+ attribute. For example, in this XML document, +foo+ is
|
|
243
|
+
# the ID attribute:
|
|
244
|
+
#
|
|
245
|
+
# <!DOCTYPE test [
|
|
246
|
+
# <!ELEMENT root EMPTY>
|
|
247
|
+
# <!ATTLIST root
|
|
248
|
+
# foo ID #REQUIRED
|
|
249
|
+
# >
|
|
250
|
+
# ]>
|
|
251
|
+
# <root foo="bar"/>
|
|
252
|
+
#
|
|
253
|
+
# ID 属性の名前を得ます。+#on_start_element+ イベント内で呼び出して
|
|
254
|
+
# ください。
|
|
255
|
+
|
|
256
|
+
##
|
|
257
|
+
# :method: reset
|
|
258
|
+
# :call-seq: reset(encoding: nil)
|
|
259
|
+
#
|
|
260
|
+
# Resets the parser object to be reused. The +encoding+ parameter
|
|
261
|
+
# can specify the character encoding.
|
|
262
|
+
#
|
|
263
|
+
# See also #external_entity_parser.
|
|
264
|
+
#
|
|
265
|
+
# パーサオブジェクトを再利用するためにリセットします。+encoding+ と
|
|
266
|
+
# して文字エンコーディングを外部から指定することもできます。
|
|
267
|
+
|
|
268
|
+
##
|
|
269
|
+
# :method: use_foreign_dtd=
|
|
270
|
+
# :call-seq: use_foreign_dtd = use_dtd
|
|
271
|
+
#
|
|
272
|
+
# Specifies to parse an external DTD subset without the
|
|
273
|
+
# DOCTYPE declaration.
|
|
274
|
+
#
|
|
275
|
+
# In +#on_external_entity_ref+, th esystem ID and the public ID will
|
|
276
|
+
# be nil.
|
|
277
|
+
#
|
|
278
|
+
# See also #param_entity_parsing=.
|
|
279
|
+
|
|
280
|
+
##
|
|
281
|
+
# :method: on_start_element
|
|
282
|
+
# :call-seq: on_start_element(name, attrs)
|
|
283
|
+
#
|
|
284
|
+
# This method is called when element start tags are detected.
|
|
285
|
+
# +name+ is the element name, +attrs+ is a hash of attributes, the
|
|
286
|
+
# keys are the attribute's name, the values are attribute's values.
|
|
287
|
+
#
|
|
288
|
+
# エレメント開始タグを見付けると呼び出されます。 +name+ はエレメント
|
|
289
|
+
# 名, +attrs+ は属性名をキー,属性値を値とするハッシュです。
|
|
290
|
+
|
|
291
|
+
##
|
|
292
|
+
# :method: on_end_element
|
|
293
|
+
# :call-seq: on_end_element(name)
|
|
294
|
+
#
|
|
295
|
+
# This method is called when element end tags are detected. +name+
|
|
296
|
+
# is the element name.
|
|
297
|
+
#
|
|
298
|
+
# エレメント終了タグを見付けると呼び出されます。 +name+ はエレメント
|
|
299
|
+
# 名です。
|
|
300
|
+
|
|
301
|
+
##
|
|
302
|
+
# :method: on_character_data
|
|
303
|
+
# :call-seq: on_character_data(data)
|
|
304
|
+
#
|
|
305
|
+
# This method is called when texts or CDATA sections are detected.
|
|
306
|
+
# Internal entities are expanded as long as +#on_default+ handler is
|
|
307
|
+
# not defined.
|
|
308
|
+
#
|
|
309
|
+
# テキスト,CDATA セクションを見付けると呼び出されます。
|
|
310
|
+
# +#on_default+ ハンドラが未定義のときは内部実体は展開されます。
|
|
311
|
+
|
|
312
|
+
##
|
|
313
|
+
# :method: on_processing_instruction
|
|
314
|
+
# :call-seq: on_processing_instruction(target, data)
|
|
315
|
+
#
|
|
316
|
+
# This method is called when processing instructions are detected.
|
|
317
|
+
#
|
|
318
|
+
# PI を見付けると呼び出されます。
|
|
319
|
+
|
|
320
|
+
##
|
|
321
|
+
# :method: on_notation_decl
|
|
322
|
+
# :call-seq: on_notation_decl(notationName, base, systemId, publicId)
|
|
323
|
+
#
|
|
324
|
+
# This methods is called when notation declarations are detected.
|
|
325
|
+
# +notationName+, +base+, +systemId+, and +publicId+ are the
|
|
326
|
+
# notation name, the URL base, the system identifier and the public
|
|
327
|
+
# identifier. The URL base, the system identifier and the public
|
|
328
|
+
# identifier can be nil.
|
|
329
|
+
#
|
|
330
|
+
# 記法宣言を見付けると呼び出されます。 +notationName+, +base+,
|
|
331
|
+
# +systemId+, +publicId+ はそれぞれ記法名,URL ベース,システム識別
|
|
332
|
+
# 子,公開識別子です。URL ベース,システム識別子,公開識別子 は nil
|
|
333
|
+
# になることがあります。
|
|
334
|
+
|
|
335
|
+
##
|
|
336
|
+
# :method: on_external_entity_ref
|
|
337
|
+
# :call-seq: on_external_entity_ref(context, base, systemId, publicId)
|
|
338
|
+
#
|
|
339
|
+
# This method is called when external entity references are
|
|
340
|
+
# detected. +context+, +base+, +systemId+, and +publicId+ are the
|
|
341
|
+
# parsing context, the URL base, the system identifier, and the
|
|
342
|
+
# public identifier. The URL base, the system identifier, and the
|
|
343
|
+
# public identifier can be nil. The context can use the +context+
|
|
344
|
+
# parameter of the constructor of the external entity parser.
|
|
345
|
+
#
|
|
346
|
+
# If you do not parse the external entities by this
|
|
347
|
+
# event, the external entities are never parsed.
|
|
348
|
+
#
|
|
349
|
+
# It is called when external parameter entity refs (including
|
|
350
|
+
# external DTD subset) are detected. In this case, +context+ will
|
|
351
|
+
# be nil. The parser for the external parameter entitiy must be
|
|
352
|
+
# created with +#parse+ in this event. See also
|
|
353
|
+
# +#param_entity_parsing=+.
|
|
354
|
+
#
|
|
355
|
+
# Example:
|
|
356
|
+
#
|
|
357
|
+
# def externalEntityRef(context, base, systemId, publicId)
|
|
358
|
+
# extp = self.type.new(self, context)
|
|
359
|
+
# file = if base.nil?; systemId; else base + "/" + systemId; end
|
|
360
|
+
# extp.parse(open(file))
|
|
361
|
+
# end
|
|
362
|
+
#
|
|
363
|
+
# 外部実体参照を見付けると呼び出されます。 +context+, +base+,
|
|
364
|
+
# +systemId+, +publicId+ はそれぞれパースコンテクスト,URL ベース,
|
|
365
|
+
# システム識別子,公開識別子です。URL ベース,公開識別子 は nil にな
|
|
366
|
+
# ることがあります。パースコンテクストは外部実体パース用のパーサを生
|
|
367
|
+
# 成するときの +context+ 引数として利用可能です。
|
|
368
|
+
#
|
|
369
|
+
# このイベントで外部実体をパースしなければ,外部実体はパースされるこ
|
|
370
|
+
# とはありません。
|
|
371
|
+
#
|
|
372
|
+
# 外部パラメータ実体参照 (および外部 DTD サブセット) を見付けた場合
|
|
373
|
+
# にも呼び出されます。この場合は +context+ は nil になります。外部パ
|
|
374
|
+
# ラメータ実体をパースする場合は必ずこのハンドラ内でパースしてくださ
|
|
375
|
+
# い。 +#param_entity_parsing=+ も参照してください。
|
|
376
|
+
|
|
377
|
+
##
|
|
378
|
+
# :method: on_comment
|
|
379
|
+
# :call-seq: on_comment(data)
|
|
380
|
+
#
|
|
381
|
+
# This methods is called when comments are detected.
|
|
382
|
+
#
|
|
383
|
+
# コメントを見付けると呼び出されます。
|
|
384
|
+
|
|
385
|
+
##
|
|
386
|
+
# :method: on_start_cdata_section
|
|
387
|
+
#
|
|
388
|
+
# This methods is called when CDATA sections start. The contents of
|
|
389
|
+
# the CDATA sections are reported by +#on_character_data+ event.
|
|
390
|
+
#
|
|
391
|
+
# CDATA セクションの開始時に呼び出されます。CDATA セクションの内容は
|
|
392
|
+
# +#on_character_data+ イベントで報告されます。
|
|
393
|
+
|
|
394
|
+
##
|
|
395
|
+
# :method: on_end_cdata_section
|
|
396
|
+
#
|
|
397
|
+
# This method is called when CDATA sections end.
|
|
398
|
+
#
|
|
399
|
+
# CDATA セクションの終了時に呼び出されます。
|
|
400
|
+
|
|
401
|
+
##
|
|
402
|
+
# :method: on_start_namespace_decl
|
|
403
|
+
# :call-seq: on_start_namespace_decl(prefix, uri)
|
|
404
|
+
#
|
|
405
|
+
# This methods is called before the element that has namespace
|
|
406
|
+
# declaration.
|
|
407
|
+
#
|
|
408
|
+
# +prefix+ and +uri+ can be nil.
|
|
409
|
+
#
|
|
410
|
+
# Note that the namespace support is enabled only when
|
|
411
|
+
# +RExpat.new+'s +nssep+ is set.
|
|
412
|
+
#
|
|
413
|
+
# Namespace 宣言されたエレメントの開始前に呼び出されます。+prefix+
|
|
414
|
+
# は xmlns 属性が指定された場合は nil になり, +uri+は空 URI が指定
|
|
415
|
+
# された場合に nil になります。
|
|
416
|
+
|
|
417
|
+
##
|
|
418
|
+
# :method: on_end_namespace_decl
|
|
419
|
+
# :call-seq: on_end_namespace_decl(prefix)
|
|
420
|
+
#
|
|
421
|
+
# This methods is called after the element that has namespace
|
|
422
|
+
# declaration.
|
|
423
|
+
#
|
|
424
|
+
# Prefix can be nil.
|
|
425
|
+
#
|
|
426
|
+
# Note that the namespace support is enabled only when
|
|
427
|
+
# +RExpat.new+'s +nssep+ is set.
|
|
428
|
+
#
|
|
429
|
+
# Namespace 宣言されたエレメントの終了後に呼び出されます。
|
|
430
|
+
# prefix は xmlns 属性が指定された場合は nil になります。
|
|
431
|
+
|
|
432
|
+
##
|
|
433
|
+
# :method: on_start_doctype_decl
|
|
434
|
+
# :call-seq: on_start_doctype_decl(doctypeName, sysid, pubid, has_internal_subset)
|
|
435
|
+
#
|
|
436
|
+
# This methods is called when the name of the DOCTYPE is
|
|
437
|
+
# encountered.
|
|
438
|
+
#
|
|
439
|
+
# DOCTYPE 宣言の文書型名を見つけると呼び出されます。
|
|
440
|
+
# +doctypeName+ は文書型名です。
|
|
441
|
+
|
|
442
|
+
##
|
|
443
|
+
# :method: on_end_doctype_decl
|
|
444
|
+
#
|
|
445
|
+
# This methods is called when the closing <tt>></tt> is encountered,
|
|
446
|
+
# but after processing any external subset.
|
|
447
|
+
#
|
|
448
|
+
# DOCTYPE 宣言の終了時に呼び出されます。
|
|
449
|
+
|
|
450
|
+
##
|
|
451
|
+
# :method: on_default
|
|
452
|
+
# :call-seq: on_default(data)
|
|
453
|
+
#
|
|
454
|
+
# This method is called when there is no applicable
|
|
455
|
+
# event handler.
|
|
456
|
+
#
|
|
457
|
+
# If this method is defined, expansion of internal
|
|
458
|
+
# entities are inhibited.
|
|
459
|
+
#
|
|
460
|
+
# 他のイベントが呼び出されなかった場合に呼び出されます。このメソッド
|
|
461
|
+
# を定義すると内部実体の展開が抑止されます。
|
|
462
|
+
|
|
463
|
+
##
|
|
464
|
+
# :method: on_default_expand
|
|
465
|
+
# :call-seq: on_default_expand(data)
|
|
466
|
+
#
|
|
467
|
+
# This method is called when there is no applicable event handlers.
|
|
468
|
+
# This is almost same as +#on_default+, except it expands internal
|
|
469
|
+
# entity references.
|
|
470
|
+
#
|
|
471
|
+
# This method have higher priority than +#on_default+ method.
|
|
472
|
+
#
|
|
473
|
+
# 他のイベントが呼び出されなかった場合に呼び出されます。
|
|
474
|
+
# +#on_default_expand+ は +#on_default+ メソッドに優先します。
|
|
475
|
+
|
|
476
|
+
##
|
|
477
|
+
# :method: on_not_standalone
|
|
478
|
+
#
|
|
479
|
+
# This methods is called if the document is not standalone (it has
|
|
480
|
+
# an external subset or a reference to a parameter entity, but does
|
|
481
|
+
# not have <tt>standalone="yes"</tt>).
|
|
482
|
+
#
|
|
483
|
+
# If you may return false to raise an error, or return true to
|
|
484
|
+
# continue the parsing.
|
|
485
|
+
#
|
|
486
|
+
# <tt>standalone="yes"</tt> でない時,外部 DTD サブセットやパラメー
|
|
487
|
+
# タ実体を参照すると呼び出されます。
|
|
488
|
+
#
|
|
489
|
+
# エラーを発生させたい場合は false,処理を続行させたい場合は true を
|
|
490
|
+
# 返してください。
|
|
491
|
+
#
|
|
492
|
+
# expat は外部 DTD サブセットやパラメータ実体を解決でき
|
|
493
|
+
# ないので,このイベントが発生した場合は他の XML プロセッ
|
|
494
|
+
# サを呼び出すなり,処理を中断するなりすべきかもしれませ
|
|
495
|
+
# ん。
|
|
496
|
+
|
|
497
|
+
##
|
|
498
|
+
# :method: on_element_decl
|
|
499
|
+
# :call-seq: on_element_decl(name, model)
|
|
500
|
+
#
|
|
501
|
+
# 要素宣言時に呼び出されます。 +name+ は要素名, +model+ は内容モデ
|
|
502
|
+
# ルをあらわす<tt>[type, quant, name, [children_model, ...]]</tt>の
|
|
503
|
+
# ような配列です。 +type+ は +:empty+, +:any+, +:mixed+, +:choice+,
|
|
504
|
+
# +:seq+ のいずれか, +quant+ は +:none+, +:opt+, +:rep+, +:plus+ の
|
|
505
|
+
# いずれかです。 +name+ は nil か要素名, +children_model+ は子モデ
|
|
506
|
+
# ルです。
|
|
507
|
+
|
|
508
|
+
##
|
|
509
|
+
# :method: on_attlist_decl
|
|
510
|
+
# :call-seq: on_attlist_decl(elname, attname, att_type, dflt, isrequired)
|
|
511
|
+
#
|
|
512
|
+
# 属性宣言時に呼び出されます。 +elname+ は要素名, +attname+ は属性
|
|
513
|
+
# 名, +att_type+ は属性の型, +dflt+ は省略値,+isrequired+ は
|
|
514
|
+
# +#REQUIRED+ かどうかをあらわします。
|
|
515
|
+
|
|
516
|
+
##
|
|
517
|
+
# :method: on_xml_decl
|
|
518
|
+
# :call-seq: on_xml_decl(version, encoding, standalone)
|
|
519
|
+
#
|
|
520
|
+
# +standalone+ can be either +nil+, +false+, or +true+, which means
|
|
521
|
+
# "no standalone attribute", "standalone attribute is set to no",
|
|
522
|
+
# and "standalone attribute is set to yes", respectably.
|
|
523
|
+
#
|
|
524
|
+
# 文書先頭の XML 宣言および解析可能実体のテキスト宣言時に呼び出され
|
|
525
|
+
# ます。テキスト宣言では +version+ が nil に,XML 宣言では
|
|
526
|
+
# +encoding+ が nil になることがあります。+standalone+ は +nil+,
|
|
527
|
+
# +false+, +true+ の値をとります。
|
|
528
|
+
|
|
529
|
+
##
|
|
530
|
+
# :method: on_entity_decl
|
|
531
|
+
# :call-seq: on_entity_decl(entityName, isparameter_entity, vale,
|
|
532
|
+
# base, systemId, publicId, notationName)
|
|
533
|
+
#
|
|
534
|
+
# 実体宣言時に呼び出されます。
|
|
535
|
+
|
|
536
|
+
##
|
|
537
|
+
# :method: on_skipped_entity
|
|
538
|
+
# :call-seq: on_skipped_entity(entityName, is_parameter_entity)
|
|
539
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
|
|
2
|
+
Copyright (c) 2001-2026 Expat maintainers
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
a copy of this software and associated documentation files (the
|
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included
|
|
13
|
+
in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
18
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
19
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
20
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
21
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
|
4
|
+
|
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
6
|
+
software without restriction, provided that you duplicate all of the
|
|
7
|
+
original copyright notices and associated disclaimers.
|
|
8
|
+
|
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
|
10
|
+
you do at least ONE of the following:
|
|
11
|
+
|
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
|
13
|
+
make them Freely Available, such as by posting said
|
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
15
|
+
the author to include your modifications in the software.
|
|
16
|
+
|
|
17
|
+
b) use the modified software only within your corporation or
|
|
18
|
+
organization.
|
|
19
|
+
|
|
20
|
+
c) give non-standard binaries non-standard names, with
|
|
21
|
+
instructions on where to get the original software distribution.
|
|
22
|
+
|
|
23
|
+
d) make other distribution arrangements with the author.
|
|
24
|
+
|
|
25
|
+
3. You may distribute the software in object code or binary form,
|
|
26
|
+
provided that you do at least ONE of the following:
|
|
27
|
+
|
|
28
|
+
a) distribute the binaries and library files of the software,
|
|
29
|
+
together with instructions (in the manual page or equivalent)
|
|
30
|
+
on where to get the original distribution.
|
|
31
|
+
|
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
|
33
|
+
the software.
|
|
34
|
+
|
|
35
|
+
c) give non-standard binaries non-standard names, with
|
|
36
|
+
instructions on where to get the original software distribution.
|
|
37
|
+
|
|
38
|
+
d) make other distribution arrangements with the author.
|
|
39
|
+
|
|
40
|
+
4. You may modify and include the part of the software into any other
|
|
41
|
+
software (possibly commercial). But some files in the distribution
|
|
42
|
+
are not written by the author, so that they are not under these terms.
|
|
43
|
+
|
|
44
|
+
For the list of those files and their copying conditions, see the
|
|
45
|
+
file LEGAL.
|
|
46
|
+
|
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
|
48
|
+
output from the software do not automatically fall under the
|
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
|
51
|
+
software.
|
|
52
|
+
|
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
56
|
+
PURPOSE.
|
data/sig/rexpat.rbs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# This work is licensed under the Ruby license or the Expat license.
|
|
2
|
+
|
|
3
|
+
module RExpat
|
|
4
|
+
VERSION: String
|
|
5
|
+
def self.expat_version: -> String
|
|
6
|
+
def self.features: -> Hash[String, Integer]
|
|
7
|
+
def initialize: (encoding: String?, nssep: String?) -> RExpat
|
|
8
|
+
def external_entity_parser: (context: String, encoding: String?) -> RExpat
|
|
9
|
+
def byte_count: -> Integer
|
|
10
|
+
def byte_index: -> Integer
|
|
11
|
+
def column: -> Integer
|
|
12
|
+
def default_current: -> void
|
|
13
|
+
def id_attribute: -> String
|
|
14
|
+
def input_context: -> [String, Integer]
|
|
15
|
+
def specified_attributes: -> Array[String]
|
|
16
|
+
def line: -> Integer
|
|
17
|
+
def reset: (encoding: String?) -> void
|
|
18
|
+
def base=: (String) -> void
|
|
19
|
+
def param_entity_parsing=: (:never | :unless_standalone | :always) -> void
|
|
20
|
+
def return_ns_triplet=: (bool) -> void
|
|
21
|
+
def use_foreign_dtd=: (bool) -> void
|
|
22
|
+
def parse: (String?, final: bool) -> void
|
|
23
|
+
def on_attlist_decl: (String, String, String?, String, bool) -> void
|
|
24
|
+
def on_character_data: (String) -> void
|
|
25
|
+
def on_comment: (String) -> void
|
|
26
|
+
def on_default: (String) -> void
|
|
27
|
+
def on_xml_decl: (String, String, bool?) -> void
|
|
28
|
+
def on_default_expand: (String) -> void
|
|
29
|
+
|
|
30
|
+
type model_type = [:empty | :any | :mixed | :choice | :seq,
|
|
31
|
+
:none | :opt | :rep | :plus,
|
|
32
|
+
String,
|
|
33
|
+
Array[model_type]]
|
|
34
|
+
|
|
35
|
+
def on_element_decl: (String, model_type) -> void
|
|
36
|
+
def on_end_cdata_section: -> void
|
|
37
|
+
def on_end_element: (String) -> void
|
|
38
|
+
def on_end_doctype_decl: -> void
|
|
39
|
+
def on_start_cdata: -> void
|
|
40
|
+
def on_not_standalone: -> bool
|
|
41
|
+
def on_end_namespace_decl: (String?) -> void
|
|
42
|
+
def on_start_namespace_decl: (String?, String?) -> void
|
|
43
|
+
def on_processing_instruction: (String, String) -> void
|
|
44
|
+
def on_start_element: (String, Hash[String, String]) -> void
|
|
45
|
+
def on_notation_decl: (String, String?, String?, String?) -> void
|
|
46
|
+
def on_start_doctype_decl: (String, String?, String?, bool) -> void
|
|
47
|
+
def on_entity_decl: (String, bool, String, String?, String?, String?, String?) -> void
|
|
48
|
+
def on_external_entity_ref: (String, String?, String?, String?) -> void
|
|
49
|
+
def on_skipped_entity: (String, bool) -> void
|
|
50
|
+
end
|