nokogiri 1.1.1-java
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/History.ja.txt +99 -0
- data/History.txt +99 -0
- data/Manifest.txt +141 -0
- data/README.ja.txt +100 -0
- data/README.txt +109 -0
- data/Rakefile +354 -0
- data/ext/nokogiri/extconf.rb +93 -0
- data/ext/nokogiri/html_document.c +86 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_sax_parser.c +36 -0
- data/ext/nokogiri/html_sax_parser.h +11 -0
- data/ext/nokogiri/native.c +41 -0
- data/ext/nokogiri/native.h +50 -0
- data/ext/nokogiri/xml_cdata.c +44 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +42 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +206 -0
- data/ext/nokogiri/xml_document.h +10 -0
- data/ext/nokogiri/xml_dtd.c +121 -0
- data/ext/nokogiri/xml_dtd.h +8 -0
- data/ext/nokogiri/xml_io.c +17 -0
- data/ext/nokogiri/xml_io.h +9 -0
- data/ext/nokogiri/xml_node.c +727 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +118 -0
- data/ext/nokogiri/xml_node_set.h +9 -0
- data/ext/nokogiri/xml_reader.c +465 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_sax_parser.c +201 -0
- data/ext/nokogiri/xml_sax_parser.h +10 -0
- data/ext/nokogiri/xml_syntax_error.c +199 -0
- data/ext/nokogiri/xml_syntax_error.h +11 -0
- data/ext/nokogiri/xml_text.c +40 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath.c +53 -0
- data/ext/nokogiri/xml_xpath.h +11 -0
- data/ext/nokogiri/xml_xpath_context.c +214 -0
- data/ext/nokogiri/xml_xpath_context.h +9 -0
- data/ext/nokogiri/xslt_stylesheet.c +123 -0
- data/ext/nokogiri/xslt_stylesheet.h +9 -0
- data/lib/action-nokogiri.rb +30 -0
- data/lib/nokogiri.rb +72 -0
- data/lib/nokogiri/css.rb +25 -0
- data/lib/nokogiri/css/generated_parser.rb +721 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +159 -0
- data/lib/nokogiri/css/node.rb +97 -0
- data/lib/nokogiri/css/parser.rb +64 -0
- data/lib/nokogiri/css/parser.y +216 -0
- data/lib/nokogiri/css/syntax_error.rb +6 -0
- data/lib/nokogiri/css/tokenizer.rb +9 -0
- data/lib/nokogiri/css/tokenizer.rex +63 -0
- data/lib/nokogiri/css/xpath_visitor.rb +168 -0
- data/lib/nokogiri/decorators.rb +2 -0
- data/lib/nokogiri/decorators/hpricot.rb +3 -0
- data/lib/nokogiri/decorators/hpricot/node.rb +56 -0
- data/lib/nokogiri/decorators/hpricot/node_set.rb +54 -0
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +28 -0
- data/lib/nokogiri/decorators/slop.rb +31 -0
- data/lib/nokogiri/hpricot.rb +51 -0
- data/lib/nokogiri/html.rb +105 -0
- data/lib/nokogiri/html/builder.rb +9 -0
- data/lib/nokogiri/html/document.rb +9 -0
- data/lib/nokogiri/html/sax/parser.rb +21 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/xml.rb +83 -0
- data/lib/nokogiri/xml/after_handler.rb +18 -0
- data/lib/nokogiri/xml/attr.rb +10 -0
- data/lib/nokogiri/xml/before_handler.rb +33 -0
- data/lib/nokogiri/xml/builder.rb +84 -0
- data/lib/nokogiri/xml/cdata.rb +9 -0
- data/lib/nokogiri/xml/comment.rb +6 -0
- data/lib/nokogiri/xml/document.rb +55 -0
- data/lib/nokogiri/xml/dtd.rb +6 -0
- data/lib/nokogiri/xml/element.rb +6 -0
- data/lib/nokogiri/xml/entity_declaration.rb +9 -0
- data/lib/nokogiri/xml/node.rb +333 -0
- data/lib/nokogiri/xml/node_set.rb +197 -0
- data/lib/nokogiri/xml/notation.rb +6 -0
- data/lib/nokogiri/xml/reader.rb +20 -0
- data/lib/nokogiri/xml/sax.rb +9 -0
- data/lib/nokogiri/xml/sax/document.rb +59 -0
- data/lib/nokogiri/xml/sax/parser.rb +37 -0
- data/lib/nokogiri/xml/syntax_error.rb +21 -0
- data/lib/nokogiri/xml/text.rb +6 -0
- data/lib/nokogiri/xml/xpath.rb +10 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +8 -0
- data/lib/nokogiri/xml/xpath_context.rb +14 -0
- data/lib/nokogiri/xslt.rb +28 -0
- data/lib/nokogiri/xslt/stylesheet.rb +6 -0
- data/test/css/test_nthiness.rb +159 -0
- data/test/css/test_parser.rb +237 -0
- data/test/css/test_tokenizer.rb +162 -0
- data/test/css/test_xpath_visitor.rb +64 -0
- data/test/files/dont_hurt_em_why.xml +422 -0
- data/test/files/exslt.xml +8 -0
- data/test/files/exslt.xslt +35 -0
- data/test/files/staff.xml +59 -0
- data/test/files/staff.xslt +32 -0
- data/test/files/tlm.html +850 -0
- data/test/helper.rb +78 -0
- data/test/hpricot/files/basic.xhtml +17 -0
- data/test/hpricot/files/boingboing.html +2266 -0
- data/test/hpricot/files/cy0.html +3653 -0
- data/test/hpricot/files/immob.html +400 -0
- data/test/hpricot/files/pace_application.html +1320 -0
- data/test/hpricot/files/tenderlove.html +16 -0
- data/test/hpricot/files/uswebgen.html +220 -0
- data/test/hpricot/files/utf8.html +1054 -0
- data/test/hpricot/files/week9.html +1723 -0
- data/test/hpricot/files/why.xml +19 -0
- data/test/hpricot/load_files.rb +11 -0
- data/test/hpricot/test_alter.rb +67 -0
- data/test/hpricot/test_builder.rb +27 -0
- data/test/hpricot/test_parser.rb +426 -0
- data/test/hpricot/test_paths.rb +15 -0
- data/test/hpricot/test_preserved.rb +77 -0
- data/test/hpricot/test_xml.rb +30 -0
- data/test/html/sax/test_parser.rb +27 -0
- data/test/html/test_builder.rb +89 -0
- data/test/html/test_document.rb +150 -0
- data/test/html/test_node.rb +21 -0
- data/test/test_convert_xpath.rb +185 -0
- data/test/test_css_cache.rb +57 -0
- data/test/test_gc.rb +15 -0
- data/test/test_memory_leak.rb +38 -0
- data/test/test_nokogiri.rb +97 -0
- data/test/test_reader.rb +222 -0
- data/test/test_xslt_transforms.rb +93 -0
- data/test/xml/sax/test_parser.rb +95 -0
- data/test/xml/test_attr.rb +15 -0
- data/test/xml/test_builder.rb +16 -0
- data/test/xml/test_cdata.rb +18 -0
- data/test/xml/test_comment.rb +16 -0
- data/test/xml/test_document.rb +195 -0
- data/test/xml/test_dtd.rb +43 -0
- data/test/xml/test_node.rb +394 -0
- data/test/xml/test_node_set.rb +143 -0
- data/test/xml/test_text.rb +13 -0
- data/test/xml/test_xpath.rb +105 -0
- data/vendor/hoe.rb +1020 -0
- metadata +233 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
#define _GNU_SOURCE
|
2
|
+
#include <stdio.h>
|
3
|
+
#include <xml_sax_parser.h>
|
4
|
+
|
5
|
+
/*
|
6
|
+
* call-seq:
|
7
|
+
* parse_memory(data)
|
8
|
+
*
|
9
|
+
* Parse the document stored in +data+
|
10
|
+
*/
|
11
|
+
static VALUE parse_memory(VALUE self, VALUE data)
|
12
|
+
{
|
13
|
+
xmlSAXHandlerPtr handler;
|
14
|
+
Data_Get_Struct(self, xmlSAXHandler, handler);
|
15
|
+
xmlSAXUserParseMemory( handler,
|
16
|
+
(void *)self,
|
17
|
+
StringValuePtr(data),
|
18
|
+
NUM2INT(rb_funcall(data, rb_intern("length"), 0))
|
19
|
+
);
|
20
|
+
return data;
|
21
|
+
}
|
22
|
+
|
23
|
+
/*
|
24
|
+
* call-seq:
|
25
|
+
* native_parse_io(data, encoding)
|
26
|
+
*
|
27
|
+
* Parse the document accessable via +io+
|
28
|
+
*/
|
29
|
+
static VALUE native_parse_io(VALUE self, VALUE io, VALUE encoding)
|
30
|
+
{
|
31
|
+
xmlSAXHandlerPtr handler;
|
32
|
+
Data_Get_Struct(self, xmlSAXHandler, handler);
|
33
|
+
|
34
|
+
xmlCharEncoding enc = (xmlCharEncoding)NUM2INT(encoding);
|
35
|
+
|
36
|
+
xmlParserCtxtPtr sax_ctx = xmlCreateIOParserCtxt(
|
37
|
+
handler,
|
38
|
+
(void *)self,
|
39
|
+
(xmlInputReadCallback)io_read_callback,
|
40
|
+
(xmlInputCloseCallback)io_close_callback,
|
41
|
+
(void *)io,
|
42
|
+
enc
|
43
|
+
);
|
44
|
+
xmlParseDocument(sax_ctx);
|
45
|
+
xmlFreeParserCtxt(sax_ctx);
|
46
|
+
return io;
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE native_parse_file(VALUE self, VALUE data)
|
50
|
+
{
|
51
|
+
xmlSAXHandlerPtr handler;
|
52
|
+
Data_Get_Struct(self, xmlSAXHandler, handler);
|
53
|
+
xmlSAXUserParseFile( handler,
|
54
|
+
(void *)self,
|
55
|
+
StringValuePtr(data)
|
56
|
+
);
|
57
|
+
return data;
|
58
|
+
}
|
59
|
+
|
60
|
+
static void start_document(void * ctx)
|
61
|
+
{
|
62
|
+
VALUE self = (VALUE)ctx;
|
63
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
64
|
+
rb_funcall(doc, rb_intern("start_document"), 0);
|
65
|
+
}
|
66
|
+
|
67
|
+
static void end_document(void * ctx)
|
68
|
+
{
|
69
|
+
VALUE self = (VALUE)ctx;
|
70
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
71
|
+
rb_funcall(doc, rb_intern("end_document"), 0);
|
72
|
+
}
|
73
|
+
|
74
|
+
static void start_element(void * ctx, const xmlChar *name, const xmlChar **atts)
|
75
|
+
{
|
76
|
+
VALUE self = (VALUE)ctx;
|
77
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
78
|
+
VALUE attributes = rb_ary_new();
|
79
|
+
const xmlChar * attr;
|
80
|
+
int i = 0;
|
81
|
+
if(atts) {
|
82
|
+
while((attr = atts[i]) != NULL) {
|
83
|
+
rb_funcall(attributes, rb_intern("<<"), 1, rb_str_new2((const char *)attr));
|
84
|
+
i++;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
rb_funcall( doc,
|
89
|
+
rb_intern("start_element"),
|
90
|
+
2,
|
91
|
+
rb_str_new2((const char *)name),
|
92
|
+
attributes
|
93
|
+
);
|
94
|
+
}
|
95
|
+
|
96
|
+
static void end_element(void * ctx, const xmlChar *name)
|
97
|
+
{
|
98
|
+
VALUE self = (VALUE)ctx;
|
99
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
100
|
+
rb_funcall(doc, rb_intern("end_element"), 1, rb_str_new2((const char *)name));
|
101
|
+
}
|
102
|
+
|
103
|
+
static void characters_func(void * ctx, const xmlChar * ch, int len)
|
104
|
+
{
|
105
|
+
VALUE self = (VALUE)ctx;
|
106
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
107
|
+
VALUE str = rb_str_new((const char *)ch, (long)len);
|
108
|
+
rb_funcall(doc, rb_intern("characters"), 1, str);
|
109
|
+
}
|
110
|
+
|
111
|
+
static void comment_func(void * ctx, const xmlChar * value)
|
112
|
+
{
|
113
|
+
VALUE self = (VALUE)ctx;
|
114
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
115
|
+
VALUE str = rb_str_new2((const char *)value);
|
116
|
+
rb_funcall(doc, rb_intern("comment"), 1, str);
|
117
|
+
}
|
118
|
+
|
119
|
+
#ifndef XP_WIN
|
120
|
+
static void warning_func(void * ctx, const char *msg, ...)
|
121
|
+
{
|
122
|
+
VALUE self = (VALUE)ctx;
|
123
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
124
|
+
char * message;
|
125
|
+
|
126
|
+
va_list args;
|
127
|
+
va_start(args, msg);
|
128
|
+
vasprintf(&message, msg, args);
|
129
|
+
va_end(args);
|
130
|
+
|
131
|
+
rb_funcall(doc, rb_intern("warning"), 1, rb_str_new2(message));
|
132
|
+
free(message);
|
133
|
+
}
|
134
|
+
#endif
|
135
|
+
|
136
|
+
#ifndef XP_WIN
|
137
|
+
static void error_func(void * ctx, const char *msg, ...)
|
138
|
+
{
|
139
|
+
VALUE self = (VALUE)ctx;
|
140
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
141
|
+
char * message;
|
142
|
+
|
143
|
+
va_list args;
|
144
|
+
va_start(args, msg);
|
145
|
+
vasprintf(&message, msg, args);
|
146
|
+
va_end(args);
|
147
|
+
|
148
|
+
rb_funcall(doc, rb_intern("error"), 1, rb_str_new2(message));
|
149
|
+
free(message);
|
150
|
+
}
|
151
|
+
#endif
|
152
|
+
|
153
|
+
static void cdata_block(void * ctx, const xmlChar * value, int len)
|
154
|
+
{
|
155
|
+
VALUE self = (VALUE)ctx;
|
156
|
+
VALUE doc = rb_funcall(self, rb_intern("document"), 0);
|
157
|
+
VALUE string = rb_str_new((const char *)value, (long)len);
|
158
|
+
rb_funcall(doc, rb_intern("cdata_block"), 1, string);
|
159
|
+
}
|
160
|
+
|
161
|
+
static void deallocate(xmlSAXHandlerPtr handler)
|
162
|
+
{
|
163
|
+
NOKOGIRI_DEBUG_START(handler);
|
164
|
+
free(handler);
|
165
|
+
NOKOGIRI_DEBUG_END(handler);
|
166
|
+
}
|
167
|
+
|
168
|
+
static VALUE allocate(VALUE klass)
|
169
|
+
{
|
170
|
+
xmlSAXHandlerPtr handler = calloc(1, sizeof(xmlSAXHandler));
|
171
|
+
|
172
|
+
handler->startDocument = start_document;
|
173
|
+
handler->endDocument = end_document;
|
174
|
+
handler->startElement = start_element;
|
175
|
+
handler->endElement = end_element;
|
176
|
+
handler->characters = characters_func;
|
177
|
+
handler->comment = comment_func;
|
178
|
+
#ifndef XP_WIN
|
179
|
+
/*
|
180
|
+
* The va*functions aren't in ming, and I don't want to deal with
|
181
|
+
* it right now.....
|
182
|
+
*
|
183
|
+
*/
|
184
|
+
handler->warning = warning_func;
|
185
|
+
handler->error = error_func;
|
186
|
+
#endif
|
187
|
+
handler->cdataBlock = cdata_block;
|
188
|
+
|
189
|
+
return Data_Wrap_Struct(klass, NULL, deallocate, handler);
|
190
|
+
}
|
191
|
+
|
192
|
+
VALUE cNokogiriXmlSaxParser ;
|
193
|
+
void init_xml_sax_parser()
|
194
|
+
{
|
195
|
+
VALUE klass = cNokogiriXmlSaxParser =
|
196
|
+
rb_const_get(mNokogiriXmlSax, rb_intern("Parser"));
|
197
|
+
rb_define_alloc_func(klass, allocate);
|
198
|
+
rb_define_method(klass, "parse_memory", parse_memory, 1);
|
199
|
+
rb_define_private_method(klass, "native_parse_file", native_parse_file, 1);
|
200
|
+
rb_define_private_method(klass, "native_parse_io", native_parse_io, 2);
|
201
|
+
}
|
@@ -0,0 +1,199 @@
|
|
1
|
+
#include <xml_syntax_error.h>
|
2
|
+
|
3
|
+
static void dealloc(xmlErrorPtr ptr)
|
4
|
+
{
|
5
|
+
NOKOGIRI_DEBUG_START(ptr);
|
6
|
+
xmlResetError(ptr);
|
7
|
+
xmlFree(ptr);
|
8
|
+
NOKOGIRI_DEBUG_END(ptr);
|
9
|
+
}
|
10
|
+
|
11
|
+
/*
|
12
|
+
* call-seq:
|
13
|
+
* column
|
14
|
+
*
|
15
|
+
* Column number or 0 if not available
|
16
|
+
*/
|
17
|
+
static VALUE column(VALUE self)
|
18
|
+
{
|
19
|
+
xmlErrorPtr error;
|
20
|
+
Data_Get_Struct(self, xmlError, error);
|
21
|
+
return INT2NUM(error->int2);
|
22
|
+
}
|
23
|
+
|
24
|
+
/*
|
25
|
+
* call-seq:
|
26
|
+
* int1
|
27
|
+
*
|
28
|
+
* Extra number information
|
29
|
+
*/
|
30
|
+
static VALUE int1(VALUE self)
|
31
|
+
{
|
32
|
+
xmlErrorPtr error;
|
33
|
+
Data_Get_Struct(self, xmlError, error);
|
34
|
+
return INT2NUM(error->int1);
|
35
|
+
}
|
36
|
+
|
37
|
+
/*
|
38
|
+
* call-seq:
|
39
|
+
* str3
|
40
|
+
*
|
41
|
+
* Extra string information
|
42
|
+
*/
|
43
|
+
static VALUE str3(VALUE self)
|
44
|
+
{
|
45
|
+
xmlErrorPtr error;
|
46
|
+
Data_Get_Struct(self, xmlError, error);
|
47
|
+
if(error->str3)
|
48
|
+
return rb_str_new2(error->str3);
|
49
|
+
return Qnil;
|
50
|
+
}
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* str2
|
55
|
+
*
|
56
|
+
* Extra string information
|
57
|
+
*/
|
58
|
+
static VALUE str2(VALUE self)
|
59
|
+
{
|
60
|
+
xmlErrorPtr error;
|
61
|
+
Data_Get_Struct(self, xmlError, error);
|
62
|
+
if(error->str2)
|
63
|
+
return rb_str_new2(error->str2);
|
64
|
+
return Qnil;
|
65
|
+
}
|
66
|
+
|
67
|
+
/*
|
68
|
+
* call-seq:
|
69
|
+
* str1
|
70
|
+
*
|
71
|
+
* Extra string information
|
72
|
+
*/
|
73
|
+
static VALUE str1(VALUE self)
|
74
|
+
{
|
75
|
+
xmlErrorPtr error;
|
76
|
+
Data_Get_Struct(self, xmlError, error);
|
77
|
+
if(error->str1)
|
78
|
+
return rb_str_new2(error->str1);
|
79
|
+
return Qnil;
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* call-seq:
|
84
|
+
* line
|
85
|
+
*
|
86
|
+
* Get the line number of the error
|
87
|
+
*/
|
88
|
+
static VALUE line(VALUE self)
|
89
|
+
{
|
90
|
+
xmlErrorPtr error;
|
91
|
+
Data_Get_Struct(self, xmlError, error);
|
92
|
+
return INT2NUM(error->line);
|
93
|
+
}
|
94
|
+
|
95
|
+
/*
|
96
|
+
* call-seq:
|
97
|
+
* file
|
98
|
+
*
|
99
|
+
* Get the filename for the error
|
100
|
+
*/
|
101
|
+
static VALUE file(VALUE self)
|
102
|
+
{
|
103
|
+
xmlErrorPtr error;
|
104
|
+
Data_Get_Struct(self, xmlError, error);
|
105
|
+
if(error->file)
|
106
|
+
return rb_str_new2(error->file);
|
107
|
+
|
108
|
+
return Qnil;
|
109
|
+
}
|
110
|
+
|
111
|
+
/*
|
112
|
+
* call-seq:
|
113
|
+
* level
|
114
|
+
*
|
115
|
+
* Get the error level
|
116
|
+
*/
|
117
|
+
static VALUE level(VALUE self)
|
118
|
+
{
|
119
|
+
xmlErrorPtr error;
|
120
|
+
Data_Get_Struct(self, xmlError, error);
|
121
|
+
return INT2NUM((short)error->level);
|
122
|
+
}
|
123
|
+
|
124
|
+
/*
|
125
|
+
* call-seq:
|
126
|
+
* code
|
127
|
+
*
|
128
|
+
* Get the error code
|
129
|
+
*/
|
130
|
+
static VALUE code(VALUE self)
|
131
|
+
{
|
132
|
+
xmlErrorPtr error;
|
133
|
+
Data_Get_Struct(self, xmlError, error);
|
134
|
+
return INT2NUM(error->code);
|
135
|
+
}
|
136
|
+
|
137
|
+
/*
|
138
|
+
* call-seq:
|
139
|
+
* domain
|
140
|
+
*
|
141
|
+
* Get the part of the library that raised this exception
|
142
|
+
*/
|
143
|
+
static VALUE domain(VALUE self)
|
144
|
+
{
|
145
|
+
xmlErrorPtr error;
|
146
|
+
Data_Get_Struct(self, xmlError, error);
|
147
|
+
return INT2NUM(error->domain);
|
148
|
+
}
|
149
|
+
|
150
|
+
/*
|
151
|
+
* call-seq:
|
152
|
+
* message
|
153
|
+
*
|
154
|
+
* Get the human readable message.
|
155
|
+
*/
|
156
|
+
static VALUE message(VALUE self)
|
157
|
+
{
|
158
|
+
xmlErrorPtr error;
|
159
|
+
Data_Get_Struct(self, xmlError, error);
|
160
|
+
return rb_str_new2(error->message);
|
161
|
+
}
|
162
|
+
|
163
|
+
void Nokogiri_error_handler(void * ctx, xmlErrorPtr error)
|
164
|
+
{
|
165
|
+
// FIXME: I'm interneting this. I *think* the pointer passed in here gets
|
166
|
+
// freed on its own, thats why I copy it.
|
167
|
+
// The files are *in* the computer.
|
168
|
+
xmlErrorPtr ptr = calloc(1, sizeof(xmlError));
|
169
|
+
xmlCopyError(error, ptr);
|
170
|
+
|
171
|
+
VALUE err = Data_Wrap_Struct(cNokogiriXmlSyntaxError, NULL, dealloc, ptr);
|
172
|
+
VALUE block = rb_funcall(mNokogiri, rb_intern("error_handler"), 0);
|
173
|
+
rb_funcall(block, rb_intern("call"), 1, err);
|
174
|
+
}
|
175
|
+
|
176
|
+
VALUE cNokogiriXmlSyntaxError;
|
177
|
+
void init_xml_syntax_error()
|
178
|
+
{
|
179
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
180
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
181
|
+
|
182
|
+
/*
|
183
|
+
* The XML::SyntaxError is raised on parse errors
|
184
|
+
*/
|
185
|
+
VALUE klass = rb_define_class_under(xml, "SyntaxError", rb_eSyntaxError);
|
186
|
+
cNokogiriXmlSyntaxError = klass;
|
187
|
+
|
188
|
+
rb_define_method(klass, "message", message, 0);
|
189
|
+
rb_define_method(klass, "domain", domain, 0);
|
190
|
+
rb_define_method(klass, "code", code, 0);
|
191
|
+
rb_define_method(klass, "level", level, 0);
|
192
|
+
rb_define_method(klass, "file", file, 0);
|
193
|
+
rb_define_method(klass, "line", line, 0);
|
194
|
+
rb_define_method(klass, "str1", str1, 0);
|
195
|
+
rb_define_method(klass, "str2", str2, 0);
|
196
|
+
rb_define_method(klass, "str3", str3, 0);
|
197
|
+
rb_define_method(klass, "int1", int1, 0);
|
198
|
+
rb_define_method(klass, "column", column, 0);
|
199
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#include <xml_text.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* new(content, document)
|
6
|
+
*
|
7
|
+
* Create a new Text element on the +document+ with +content+
|
8
|
+
*/
|
9
|
+
static VALUE new(VALUE klass, VALUE string, VALUE document)
|
10
|
+
{
|
11
|
+
xmlDocPtr doc;
|
12
|
+
Data_Get_Struct(document, xmlDoc, doc);
|
13
|
+
|
14
|
+
xmlNodePtr node = xmlNewText((xmlChar *)StringValuePtr(string));
|
15
|
+
node->doc = doc;
|
16
|
+
|
17
|
+
VALUE rb_node = Nokogiri_wrap_xml_node(node) ;
|
18
|
+
|
19
|
+
if(rb_block_given_p()) rb_yield(rb_node);
|
20
|
+
|
21
|
+
return rb_node;
|
22
|
+
}
|
23
|
+
|
24
|
+
VALUE cNokogiriXmlText ;
|
25
|
+
void init_xml_text()
|
26
|
+
{
|
27
|
+
VALUE nokogiri = rb_define_module("Nokogiri");
|
28
|
+
VALUE xml = rb_define_module_under(nokogiri, "XML");
|
29
|
+
/* */
|
30
|
+
VALUE node = rb_define_class_under(xml, "Node", rb_cObject);
|
31
|
+
|
32
|
+
/*
|
33
|
+
* Wraps Text nodes.
|
34
|
+
*/
|
35
|
+
VALUE klass = rb_define_class_under(xml, "Text", node);
|
36
|
+
|
37
|
+
cNokogiriXmlText = klass;
|
38
|
+
|
39
|
+
rb_define_singleton_method(klass, "new", new, 2);
|
40
|
+
}
|