nokogiri 1.4.0-x86-mingw32 → 1.4.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data/.autotest +5 -6
- data/CHANGELOG.ja.rdoc +47 -11
- data/CHANGELOG.rdoc +31 -0
- data/Manifest.txt +8 -1
- data/README.ja.rdoc +4 -3
- data/README.rdoc +9 -1
- data/Rakefile +4 -0
- data/deps.rip +5 -0
- data/ext/nokogiri/extconf.rb +4 -0
- data/ext/nokogiri/html_element_description.c +1 -1
- data/ext/nokogiri/nokogiri.c +7 -0
- data/ext/nokogiri/nokogiri.h +4 -1
- data/ext/nokogiri/xml_document.c +3 -5
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_namespace.c +8 -0
- data/ext/nokogiri/xml_namespace.h +1 -0
- data/ext/nokogiri/xml_node.c +61 -41
- data/ext/nokogiri/xml_node_set.c +22 -14
- data/ext/nokogiri/xml_sax_parser.c +0 -3
- data/ext/nokogiri/xml_sax_parser_context.c +2 -0
- data/ext/nokogiri/xml_sax_push_parser.c +26 -3
- data/ext/nokogiri/xml_syntax_error.c +18 -227
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css/generated_parser.rb +173 -160
- data/lib/nokogiri/css/generated_tokenizer.rb +4 -1
- data/lib/nokogiri/css/parser.y +4 -1
- data/lib/nokogiri/css/tokenizer.rex +2 -1
- data/lib/nokogiri/css/xpath_visitor.rb +2 -0
- data/lib/nokogiri/ffi/encoding_handler.rb +42 -0
- data/lib/nokogiri/ffi/html/element_description.rb +5 -9
- data/lib/nokogiri/ffi/libxml.rb +21 -5
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_document.rb +3 -3
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +110 -1
- data/lib/nokogiri/ffi/xml/dtd.rb +2 -4
- data/lib/nokogiri/ffi/xml/node.rb +38 -17
- data/lib/nokogiri/ffi/xml/node_set.rb +21 -8
- data/lib/nokogiri/ffi/xml/reader.rb +1 -1
- data/lib/nokogiri/ffi/xml/sax/parser.rb +1 -8
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +16 -4
- data/lib/nokogiri/ffi/xml/syntax_error.rb +9 -2
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +12 -9
- data/lib/nokogiri/version.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +35 -4
- data/lib/nokogiri/xml/document_fragment.rb +5 -1
- data/lib/nokogiri/xml/fragment_handler.rb +28 -20
- data/lib/nokogiri/xml/node.rb +84 -13
- data/lib/nokogiri/xml/node_set.rb +19 -2
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -1
- data/lib/nokogiri/xml/syntax_error.rb +10 -5
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/lib/xsd/xmlparser/nokogiri.rb +20 -1
- data/test/css/test_parser.rb +5 -0
- data/test/css/test_tokenizer.rb +7 -0
- data/test/helper.rb +0 -5
- data/test/html/test_document_fragment.rb +39 -1
- data/test/html/test_node.rb +14 -0
- data/test/test_encoding_handler.rb +46 -0
- data/test/test_memory_leak.rb +10 -0
- data/test/test_nokogiri.rb +5 -1
- data/test/test_soap4r_sax.rb +52 -0
- data/test/test_xslt_transforms.rb +69 -26
- data/test/xml/sax/test_parser_context.rb +7 -0
- data/test/xml/sax/test_push_parser.rb +33 -0
- data/test/xml/test_document.rb +27 -1
- data/test/xml/test_document_fragment.rb +6 -0
- data/test/xml/test_node.rb +63 -214
- data/test/xml/test_node_reparenting.rb +261 -0
- data/test/xml/test_node_set.rb +51 -0
- data/test/xml/test_syntax_error.rb +0 -15
- metadata +13 -4
- data/test/test_gc.rb +0 -15
data/.autotest
CHANGED
@@ -5,6 +5,11 @@ begin
|
|
5
5
|
rescue LoadError
|
6
6
|
end
|
7
7
|
|
8
|
+
Autotest.add_hook :initialize do |at|
|
9
|
+
at.add_exception /bundle$/
|
10
|
+
at.add_exception /\.git/
|
11
|
+
end
|
12
|
+
|
8
13
|
Autotest.add_hook :run_command do |at|
|
9
14
|
at.unit_diff = 'cat'
|
10
15
|
if ENV['ONENINE']
|
@@ -19,9 +24,3 @@ Autotest.add_hook :ran_command do |at|
|
|
19
24
|
f.write(at.results.join)
|
20
25
|
}
|
21
26
|
end
|
22
|
-
|
23
|
-
class Autotest
|
24
|
-
def ruby
|
25
|
-
'ruby1.9'
|
26
|
-
end
|
27
|
-
end if ENV['ONENINE']
|
data/CHANGELOG.ja.rdoc
CHANGED
@@ -1,16 +1,52 @@
|
|
1
|
+
=== 1.4.1 2009年12月10日
|
2
|
+
|
3
|
+
* 新しい機能
|
4
|
+
* Nokogiri::LIBXML_ICONV_ENABLED を追加
|
5
|
+
* Node#attr は Node#[] のエイリアス定義に変更
|
6
|
+
* XML::Node#next_element を追加
|
7
|
+
* 直接の子ノードを検索するための Node#> を追加
|
8
|
+
* XML::NodeSet#reverse を追加
|
9
|
+
* 以下のfragment supportを追加
|
10
|
+
Node#add_child
|
11
|
+
Node#add_next_sibling
|
12
|
+
Node#add_previous_sibling
|
13
|
+
Node#replace
|
14
|
+
* XML::Node#previous_element を追加
|
15
|
+
* nokogiriがRubinius でサポートされるようになった
|
16
|
+
* CSS selector の :has() が使用可能になった
|
17
|
+
* XML::NodeSet#filter() を追加
|
18
|
+
* XML::Node.next= は add_next_sibling の alias へ変更
|
19
|
+
* XML::Node.previous= は add_previous_sibling の alias へ変更
|
20
|
+
|
21
|
+
* バグの修正
|
22
|
+
* XMLのフラグメントに名前空間が存在する場合のみ、DocumentFragmentを作る際に、
|
23
|
+
例外が投げられなくなった
|
24
|
+
* DocumentFragment内で子ノードが存在する場合、
|
25
|
+
Node#matches?が機能するようになった GH #158
|
26
|
+
* Documentは add_namespace()を限定すべきではないので削除GH #169
|
27
|
+
* XPath クエリは名前空間の宣言を変換するがsegvではない。
|
28
|
+
* Node#replace は他のドキュメントのノードが使えるようになった
|
29
|
+
* XML::Document#collect_namespaces を追加
|
30
|
+
* SOAP4R のアダプター内のバグ修正
|
31
|
+
* XML::Node#next_element 内のバグ修正
|
32
|
+
* WindowsでのJRuby の LOAD_PATH を修正 GH #160
|
33
|
+
* XSLT#apply_toは "output method"の値を使用する(richardlehaneに感謝)
|
34
|
+
* 新しい文字列の先頭にくるテキストノードを含んだフレグメントが 正確に
|
35
|
+
解析出来るようになった GH #178
|
36
|
+
|
1
37
|
=== 1.4.0 2009年10月30日
|
2
38
|
|
3
39
|
* 今日はノコギリの満一歳のお誕生日です
|
4
40
|
|
5
41
|
* 新しい機能
|
6
|
-
* Node#at_xpath はXPath
|
7
|
-
* Node#at_css はCSS
|
8
|
-
* NodeSet#|
|
9
|
-
* NodeSet#inspect
|
10
|
-
* Node#inspect
|
42
|
+
* Node#at_xpath はXPath式に適合するNodeSetの一番最初の要素を返す
|
43
|
+
* Node#at_css はCSSセレクターに適合するNodeSetの一番最初の要素を返す
|
44
|
+
* NodeSet#| はNodeSet同士を合成する GH #119 (Serabe ありがとう!)
|
45
|
+
* NodeSet#inspect の出力をより美しくした
|
46
|
+
* Node#inspect の出力をよりrubyらしくした
|
11
47
|
* XML::DTD#external_id を追加
|
12
48
|
* XML::DTD#system_id を追加
|
13
|
-
* XML::ElementContent はDTD
|
49
|
+
* XML::ElementContent はDTD要素のコンテンツを有効化する
|
14
50
|
* Nokogiri::XML::Builder内での名前空間宣言用のサポートを改良
|
15
51
|
* XML::Node#external_subsetを追加
|
16
52
|
* XML::Node#create_external_subsetを追加
|
@@ -32,12 +68,12 @@
|
|
32
68
|
SEGVを修正するようになった
|
33
69
|
* Node#inner_html がNode#to_html と同じ独立変数を受け入れるようになった
|
34
70
|
GH #117
|
35
|
-
* DocumentFragment#css
|
36
|
-
* NodeSet#[]がNodeSet#length
|
71
|
+
* DocumentFragment#css は子ノードへ委任するようになった GH #123
|
72
|
+
* NodeSet#[]がNodeSet#lengthより大きいスライスでも機能するようになった
|
37
73
|
GH #131
|
38
|
-
*
|
39
|
-
* XML::Document をNodeSet
|
40
|
-
* XML::SyntaxError
|
74
|
+
* 新たな親ノードの名前空間を維持出来るようになった GH #134
|
75
|
+
* XML::Document をNodeSetに追加する際のSEGVが修正された
|
76
|
+
* XML::SyntaxError が複製可能になった
|
41
77
|
|
42
78
|
* 廃棄予定
|
43
79
|
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,34 @@
|
|
1
|
+
=== HEAD
|
2
|
+
|
3
|
+
* New Features
|
4
|
+
|
5
|
+
* Added Nokogiri::LIBXML_ICONV_ENABLED
|
6
|
+
* Alias Node#[] to Node#attr
|
7
|
+
* XML::Node#next_element added
|
8
|
+
* XML::Node#> added for searching a nodes immediate children
|
9
|
+
* XML::NodeSet#reverse added
|
10
|
+
* Added fragment support to Node#add_child, Node#add_next_sibling,
|
11
|
+
Node#add_previous_sibling, and Node#replace.
|
12
|
+
* XML::Node#previous_element implemented
|
13
|
+
* Rubinius support
|
14
|
+
* Ths CSS selector engine now supports :has()
|
15
|
+
* XML::NodeSet#filter() was added
|
16
|
+
* XML::Node.next= and .previous= are aliases for add_next_sibling and add_previous_sibling. GH #183
|
17
|
+
|
18
|
+
* Bugfixes
|
19
|
+
|
20
|
+
* XML fragments with namespaces do not raise an exception (regression in 1.4.0)
|
21
|
+
* Node#matches? works in nodes contained by a DocumentFragment. GH #158
|
22
|
+
* Document should not define add_namespace() method. GH #169
|
23
|
+
* XPath queries returning namespace declarations do not segfault.
|
24
|
+
* Node#replace works with nodes from different documents. GH #162
|
25
|
+
* Adding XML::Document#collect_namespaces
|
26
|
+
* Fixed bugs in the SOAP4R adapter
|
27
|
+
* Fixed bug in XML::Node#next_element for certain edge cases
|
28
|
+
* Fixed load path issue with JRuby under Windows. GH #160.
|
29
|
+
* XSLT#apply_to will honor the "output method". Thanks richardlehane!
|
30
|
+
* Fragments containing leading text nodes with newlines now parse properly. GH #178.
|
31
|
+
|
1
32
|
=== 1.4.0 / 2009/10/30
|
2
33
|
|
3
34
|
* Happy Birthday!
|
data/Manifest.txt
CHANGED
@@ -6,6 +6,7 @@ README.ja.rdoc
|
|
6
6
|
README.rdoc
|
7
7
|
Rakefile
|
8
8
|
bin/nokogiri
|
9
|
+
deps.rip
|
9
10
|
ext/nokogiri/extconf.rb
|
10
11
|
ext/nokogiri/html_document.c
|
11
12
|
ext/nokogiri/html_document.h
|
@@ -35,6 +36,8 @@ ext/nokogiri/xml_element_content.c
|
|
35
36
|
ext/nokogiri/xml_element_content.h
|
36
37
|
ext/nokogiri/xml_element_decl.c
|
37
38
|
ext/nokogiri/xml_element_decl.h
|
39
|
+
ext/nokogiri/xml_encoding_handler.c
|
40
|
+
ext/nokogiri/xml_encoding_handler.h
|
38
41
|
ext/nokogiri/xml_entity_decl.c
|
39
42
|
ext/nokogiri/xml_entity_decl.h
|
40
43
|
ext/nokogiri/xml_entity_reference.c
|
@@ -83,6 +86,7 @@ lib/nokogiri/css/tokenizer.rb
|
|
83
86
|
lib/nokogiri/css/tokenizer.rex
|
84
87
|
lib/nokogiri/css/xpath_visitor.rb
|
85
88
|
lib/nokogiri/decorators/slop.rb
|
89
|
+
lib/nokogiri/ffi/encoding_handler.rb
|
86
90
|
lib/nokogiri/ffi/html/document.rb
|
87
91
|
lib/nokogiri/ffi/html/element_description.rb
|
88
92
|
lib/nokogiri/ffi/html/entity_lookup.rb
|
@@ -96,6 +100,7 @@ lib/nokogiri/ffi/structs/xml_alloc.rb
|
|
96
100
|
lib/nokogiri/ffi/structs/xml_attr.rb
|
97
101
|
lib/nokogiri/ffi/structs/xml_attribute.rb
|
98
102
|
lib/nokogiri/ffi/structs/xml_buffer.rb
|
103
|
+
lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb
|
99
104
|
lib/nokogiri/ffi/structs/xml_document.rb
|
100
105
|
lib/nokogiri/ffi/structs/xml_dtd.rb
|
101
106
|
lib/nokogiri/ffi/structs/xml_element.rb
|
@@ -229,10 +234,11 @@ test/html/test_node.rb
|
|
229
234
|
test/html/test_node_encoding.rb
|
230
235
|
test/test_convert_xpath.rb
|
231
236
|
test/test_css_cache.rb
|
232
|
-
test/
|
237
|
+
test/test_encoding_handler.rb
|
233
238
|
test/test_memory_leak.rb
|
234
239
|
test/test_nokogiri.rb
|
235
240
|
test/test_reader.rb
|
241
|
+
test/test_soap4r_sax.rb
|
236
242
|
test/test_xslt_transforms.rb
|
237
243
|
test/xml/node/test_save_options.rb
|
238
244
|
test/xml/node/test_subclass.rb
|
@@ -257,6 +263,7 @@ test/xml/test_namespace.rb
|
|
257
263
|
test/xml/test_node.rb
|
258
264
|
test/xml/test_node_attributes.rb
|
259
265
|
test/xml/test_node_encoding.rb
|
266
|
+
test/xml/test_node_reparenting.rb
|
260
267
|
test/xml/test_node_set.rb
|
261
268
|
test/xml/test_parse_options.rb
|
262
269
|
test/xml/test_processing_instruction.rb
|
data/README.ja.rdoc
CHANGED
@@ -28,11 +28,12 @@ XML/HTMLの高速な解析と探索検索、ならびにCSS3セレクタとXPath
|
|
28
28
|
|
29
29
|
== SUPPORT:
|
30
30
|
|
31
|
-
Nokogiri
|
31
|
+
日本語でNokogiriの
|
32
|
+
{メーリングリスト}[http://groups.google.com/group/nokogiri-list]
|
32
33
|
|
33
|
-
* http://groups.google.com/group/nokogiri-
|
34
|
+
* http://groups.google.com/group/nokogiri-list
|
34
35
|
|
35
|
-
|
36
|
+
{バグ報告}[http://github.com/tenderlove/nokogiri/issues]
|
36
37
|
|
37
38
|
* http://github.com/tenderlove/nokogiri/issues
|
38
39
|
|
data/README.rdoc
CHANGED
@@ -34,7 +34,8 @@ is available here:
|
|
34
34
|
|
35
35
|
* http://groups.google.com/group/nokogiri-talk
|
36
36
|
|
37
|
-
The bug tracker
|
37
|
+
The {bug tracker}[http://github.com/tenderlove/nokogiri/issues]
|
38
|
+
is available here:
|
38
39
|
|
39
40
|
* http://github.com/tenderlove/nokogiri/issues
|
40
41
|
|
@@ -82,6 +83,13 @@ The IRC channel is #nokogiri on freenode.
|
|
82
83
|
|
83
84
|
* sudo gem install nokogiri
|
84
85
|
|
86
|
+
=== Binary packages
|
87
|
+
|
88
|
+
Binary packages are available for:
|
89
|
+
|
90
|
+
* SuSE[http://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/]
|
91
|
+
* Fedora[https://admin.fedoraproject.org/pkgdb/packages/name/rubygem-nokogiri]
|
92
|
+
|
85
93
|
== DEVELOPMENT:
|
86
94
|
|
87
95
|
Developing Nokogiri requires racc and rexical.
|
data/Rakefile
CHANGED
data/deps.rip
ADDED
data/ext/nokogiri/extconf.rb
CHANGED
@@ -4,6 +4,8 @@ ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
|
4
4
|
|
5
5
|
require 'mkmf'
|
6
6
|
|
7
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
8
|
+
|
7
9
|
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
8
10
|
LIBDIR = Config::CONFIG['libdir']
|
9
11
|
INCLUDEDIR = Config::CONFIG['includedir']
|
@@ -13,6 +15,8 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
|
13
15
|
end
|
14
16
|
|
15
17
|
$CFLAGS << " #{ENV["CFLAGS"]}"
|
18
|
+
$LIBS << " #{ENV["LIBS"]}"
|
19
|
+
|
16
20
|
if Config::CONFIG['target_os'] == 'mingw32'
|
17
21
|
$CFLAGS << " -DXP_WIN -DXP_WIN32 -DUSE_INCLUDED_VASPRINTF"
|
18
22
|
elsif Config::CONFIG['target_os'] == 'solaris2'
|
@@ -242,7 +242,7 @@ static VALUE get_description(VALUE klass, VALUE tag_name)
|
|
242
242
|
);
|
243
243
|
|
244
244
|
if(NULL == description) return Qnil;
|
245
|
-
return Data_Wrap_Struct(klass, 0, 0, description);
|
245
|
+
return Data_Wrap_Struct(klass, 0, 0, (void *)description);
|
246
246
|
}
|
247
247
|
|
248
248
|
VALUE cNokogiriHtmlElementDescription ;
|
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -53,6 +53,12 @@ void Init_nokogiri()
|
|
53
53
|
NOKOGIRI_STR_NEW2(xmlParserVersion)
|
54
54
|
);
|
55
55
|
|
56
|
+
#ifdef LIBXML_ICONV_ENABLED
|
57
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue);
|
58
|
+
#else
|
59
|
+
rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse);
|
60
|
+
#endif
|
61
|
+
|
56
62
|
xmlInitParser();
|
57
63
|
|
58
64
|
init_xml_document();
|
@@ -86,4 +92,5 @@ void Init_nokogiri()
|
|
86
92
|
init_xml_schema();
|
87
93
|
init_xml_relax_ng();
|
88
94
|
init_nokogiri_io();
|
95
|
+
init_xml_encoding_handler();
|
89
96
|
}
|
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -68,6 +68,9 @@ int is_2_6_16(void) ;
|
|
68
68
|
rb_str_new((const char *)str, (long)len)
|
69
69
|
#endif
|
70
70
|
|
71
|
+
#define RBSTR_OR_QNIL(_str) \
|
72
|
+
(_str ? NOKOGIRI_STR_NEW2(_str) : Qnil)
|
73
|
+
|
71
74
|
#include <xml_io.h>
|
72
75
|
#include <xml_document.h>
|
73
76
|
#include <html_entity_lookup.h>
|
@@ -99,6 +102,7 @@ int is_2_6_16(void) ;
|
|
99
102
|
#include <xml_relax_ng.h>
|
100
103
|
#include <html_element_description.h>
|
101
104
|
#include <xml_namespace.h>
|
105
|
+
#include <xml_encoding_handler.h>
|
102
106
|
|
103
107
|
extern VALUE mNokogiri ;
|
104
108
|
extern VALUE mNokogiriXml ;
|
@@ -111,7 +115,6 @@ extern VALUE mNokogiriXslt ;
|
|
111
115
|
({ \
|
112
116
|
nokogiriTuplePtr tuple = (nokogiriTuplePtr)(_node->doc->_private); \
|
113
117
|
st_insert(tuple->unlinkedNodes, (st_data_t)_node, (st_data_t)_node); \
|
114
|
-
_node; \
|
115
118
|
})
|
116
119
|
|
117
120
|
#ifdef DEBUG
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -260,7 +260,7 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
|
|
260
260
|
if(dup == NULL) return Qnil;
|
261
261
|
|
262
262
|
dup->type = doc->type;
|
263
|
-
return Nokogiri_wrap_xml_document(
|
263
|
+
return Nokogiri_wrap_xml_document(rb_obj_class(self), dup);
|
264
264
|
}
|
265
265
|
|
266
266
|
/*
|
@@ -275,9 +275,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
275
275
|
|
276
276
|
rb_scan_args(argc, argv, "0*", &rest);
|
277
277
|
version = rb_ary_entry(rest, (long)0);
|
278
|
-
if (NIL_P(
|
279
|
-
version = rb_str_new2("1.0");
|
280
|
-
}
|
278
|
+
if (NIL_P(version)) version = rb_str_new2("1.0");
|
281
279
|
|
282
280
|
xmlDocPtr doc = xmlNewDoc((xmlChar *)StringValuePtr(version));
|
283
281
|
rb_doc = Nokogiri_wrap_xml_document(klass, doc);
|
@@ -327,7 +325,7 @@ VALUE remove_namespaces_bang(VALUE self)
|
|
327
325
|
xmlDocPtr doc ;
|
328
326
|
Data_Get_Struct(self, xmlDoc, doc);
|
329
327
|
|
330
|
-
recursively_remove_namespaces_from_node(doc);
|
328
|
+
recursively_remove_namespaces_from_node((xmlNodePtr)doc);
|
331
329
|
return self;
|
332
330
|
}
|
333
331
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#include <xml_encoding_handler.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq: Nokogiri::EncodingHandler.[](name)
|
5
|
+
*
|
6
|
+
* Get the encoding handler for +name+
|
7
|
+
*/
|
8
|
+
static VALUE get(VALUE klass, VALUE key)
|
9
|
+
{
|
10
|
+
xmlCharEncodingHandlerPtr handler;
|
11
|
+
|
12
|
+
handler = xmlFindCharEncodingHandler(StringValuePtr(key));
|
13
|
+
if(handler)
|
14
|
+
return Data_Wrap_Struct(klass, NULL, NULL, handler);
|
15
|
+
|
16
|
+
return Qnil;
|
17
|
+
}
|
18
|
+
|
19
|
+
/*
|
20
|
+
* call-seq: Nokogiri::EncodingHandler.delete(name)
|
21
|
+
*
|
22
|
+
* Delete the encoding alias named +name+
|
23
|
+
*/
|
24
|
+
static VALUE delete(VALUE klass, VALUE name)
|
25
|
+
{
|
26
|
+
if(xmlDelEncodingAlias(StringValuePtr(name))) return Qnil;
|
27
|
+
|
28
|
+
return Qtrue;
|
29
|
+
}
|
30
|
+
|
31
|
+
/*
|
32
|
+
* call-seq: Nokogiri::EncodingHandler.alias(from, to)
|
33
|
+
*
|
34
|
+
* Alias encoding handler with name +from+ to name +to+
|
35
|
+
*/
|
36
|
+
static VALUE alias(VALUE klass, VALUE from, VALUE to)
|
37
|
+
{
|
38
|
+
xmlAddEncodingAlias(StringValuePtr(from), StringValuePtr(to));
|
39
|
+
|
40
|
+
return to;
|
41
|
+
}
|
42
|
+
|
43
|
+
/*
|
44
|
+
* call-seq: Nokogiri::EncodingHandler.clear_aliases!
|
45
|
+
*
|
46
|
+
* Remove all encoding aliases.
|
47
|
+
*/
|
48
|
+
static VALUE clear_aliases(VALUE klass)
|
49
|
+
{
|
50
|
+
xmlCleanupEncodingAliases();
|
51
|
+
|
52
|
+
return klass;
|
53
|
+
}
|
54
|
+
|
55
|
+
/*
|
56
|
+
* call-seq: name
|
57
|
+
*
|
58
|
+
* Get the name of this EncodingHandler
|
59
|
+
*/
|
60
|
+
static VALUE name(VALUE self)
|
61
|
+
{
|
62
|
+
xmlCharEncodingHandlerPtr handler;
|
63
|
+
|
64
|
+
Data_Get_Struct(self, xmlCharEncodingHandler, handler);
|
65
|
+
|
66
|
+
return NOKOGIRI_STR_NEW2(handler->name);
|
67
|
+
}
|
68
|
+
|
69
|
+
void init_xml_encoding_handler()
|
70
|
+
{
|
71
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
72
|
+
VALUE klass = rb_define_class_under(nokogiri, "EncodingHandler", rb_cObject);
|
73
|
+
|
74
|
+
rb_define_singleton_method(klass, "[]", get, 1);
|
75
|
+
rb_define_singleton_method(klass, "delete", delete, 1);
|
76
|
+
rb_define_singleton_method(klass, "alias", alias, 2);
|
77
|
+
rb_define_singleton_method(klass, "clear_aliases!", clear_aliases, 0);
|
78
|
+
rb_define_method(klass, "name", name, 0);
|
79
|
+
}
|
@@ -61,6 +61,14 @@ VALUE Nokogiri_wrap_xml_namespace(xmlDocPtr doc, xmlNsPtr node)
|
|
61
61
|
return ns;
|
62
62
|
}
|
63
63
|
|
64
|
+
VALUE Nokogiri_wrap_xml_namespace2(VALUE document, xmlNsPtr node)
|
65
|
+
{
|
66
|
+
xmlDocPtr doc;
|
67
|
+
Data_Get_Struct(document, xmlDoc, doc) ;
|
68
|
+
return Nokogiri_wrap_xml_namespace(doc, node);
|
69
|
+
}
|
70
|
+
|
71
|
+
|
64
72
|
void init_xml_namespace()
|
65
73
|
{
|
66
74
|
VALUE nokogiri = rb_define_module("Nokogiri");
|