nokogiri 1.4.1-x86-mswin32 → 1.4.2.1-x86-mswin32
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/CHANGELOG.ja.rdoc +45 -0
- data/CHANGELOG.rdoc +53 -1
- data/Manifest.txt +3 -3
- data/README.ja.rdoc +1 -1
- data/README.rdoc +11 -5
- data/Rakefile +13 -79
- data/ext/nokogiri/extconf.rb +25 -74
- data/ext/nokogiri/html_document.c +17 -8
- data/ext/nokogiri/html_element_description.c +20 -16
- data/ext/nokogiri/html_entity_lookup.c +2 -2
- data/ext/nokogiri/html_sax_parser_context.c +10 -8
- data/ext/nokogiri/nokogiri.c +0 -1
- data/ext/nokogiri/nokogiri.h +33 -28
- data/ext/nokogiri/xml_attr.c +7 -5
- data/ext/nokogiri/xml_attribute_decl.c +5 -2
- data/ext/nokogiri/xml_cdata.c +4 -2
- data/ext/nokogiri/xml_comment.c +4 -2
- data/ext/nokogiri/xml_document.c +93 -15
- data/ext/nokogiri/xml_document.h +0 -1
- data/ext/nokogiri/xml_document_fragment.c +4 -2
- data/ext/nokogiri/xml_dtd.c +18 -8
- data/ext/nokogiri/xml_element_content.c +2 -2
- data/ext/nokogiri/xml_entity_decl.c +15 -2
- data/ext/nokogiri/xml_entity_reference.c +4 -2
- data/ext/nokogiri/xml_io.c +1 -1
- data/ext/nokogiri/xml_namespace.c +5 -3
- data/ext/nokogiri/xml_node.c +353 -114
- data/ext/nokogiri/xml_node_set.c +35 -22
- data/ext/nokogiri/xml_node_set.h +1 -1
- data/ext/nokogiri/xml_processing_instruction.c +4 -2
- data/ext/nokogiri/xml_reader.c +119 -47
- data/ext/nokogiri/xml_relax_ng.c +21 -12
- data/ext/nokogiri/xml_sax_parser.c +6 -3
- data/ext/nokogiri/xml_sax_parser.h +13 -17
- data/ext/nokogiri/xml_sax_parser_context.c +8 -6
- data/ext/nokogiri/xml_sax_push_parser.c +7 -6
- data/ext/nokogiri/xml_schema.c +62 -13
- data/ext/nokogiri/xml_syntax_error.c +18 -12
- data/ext/nokogiri/xml_syntax_error.h +1 -1
- data/ext/nokogiri/xml_text.c +4 -2
- data/ext/nokogiri/xml_xpath_context.c +60 -23
- data/ext/nokogiri/xslt_stylesheet.c +14 -3
- data/lib/nokogiri.rb +17 -0
- 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 +72 -62
- data/lib/nokogiri/css/generated_tokenizer.rb +23 -23
- data/lib/nokogiri/css/parser.y +3 -1
- data/lib/nokogiri/css/tokenizer.rex +3 -3
- data/lib/nokogiri/css/xpath_visitor.rb +8 -3
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +3 -3
- data/lib/nokogiri/ffi/libxml.rb +16 -2
- data/lib/nokogiri/ffi/structs/common_node.rb +15 -3
- data/lib/nokogiri/ffi/structs/xml_document.rb +13 -4
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +3 -2
- data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
- data/lib/nokogiri/ffi/xml/document.rb +27 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +9 -0
- data/lib/nokogiri/ffi/xml/node.rb +142 -61
- data/lib/nokogiri/ffi/xml/node_set.rb +15 -12
- data/lib/nokogiri/ffi/xml/reader.rb +5 -0
- data/lib/nokogiri/ffi/xml/schema.rb +17 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +4 -4
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -10
- data/lib/nokogiri/ffi/xml/xpath_context.rb +22 -9
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +3 -0
- data/lib/nokogiri/html/document.rb +5 -3
- data/lib/nokogiri/html/document_fragment.rb +28 -7
- data/lib/nokogiri/version.rb +6 -2
- data/lib/nokogiri/version_warning.rb +6 -3
- data/lib/nokogiri/xml.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +35 -22
- data/lib/nokogiri/xml/document.rb +44 -12
- data/lib/nokogiri/xml/document_fragment.rb +16 -12
- data/lib/nokogiri/xml/entity_decl.rb +4 -0
- data/lib/nokogiri/xml/node.rb +152 -95
- data/lib/nokogiri/xml/node_set.rb +2 -1
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -1
- data/lib/nokogiri/xml/schema.rb +1 -5
- data/lib/nokogiri/xml/syntax_error.rb +4 -0
- data/lib/nokogiri/xml/text.rb +9 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +3 -0
- data/tasks/cross_compile.rb +158 -0
- data/tasks/test.rb +0 -6
- data/test/css/test_xpath_visitor.rb +9 -0
- data/test/helper.rb +49 -11
- data/test/html/sax/test_parser.rb +11 -1
- data/test/html/test_document.rb +8 -0
- data/test/html/test_document_fragment.rb +14 -2
- data/test/html/test_element_description.rb +5 -1
- data/test/html/test_node.rb +5 -66
- data/test/test_reader.rb +28 -0
- data/test/test_xslt_transforms.rb +14 -0
- data/test/xml/test_builder.rb +43 -0
- data/test/xml/test_cdata.rb +12 -0
- data/test/xml/test_document.rb +74 -39
- data/test/xml/test_document_fragment.rb +36 -0
- data/test/xml/test_entity_decl.rb +37 -0
- data/test/xml/test_node.rb +192 -65
- data/test/xml/test_node_reparenting.rb +253 -236
- data/test/xml/test_node_set.rb +67 -0
- data/test/xml/test_text.rb +8 -0
- data/test/xml/test_xpath.rb +32 -0
- metadata +151 -79
- data/ext/nokogiri/iconv.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/xml_xpath.c +0 -53
- data/ext/nokogiri/xml_xpath.h +0 -11
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri/xml/fragment_handler.rb +0 -79
@@ -9,12 +9,13 @@
|
|
9
9
|
static VALUE new(int argc, VALUE *argv, VALUE klass)
|
10
10
|
{
|
11
11
|
VALUE uri, external_id, rest, rb_doc;
|
12
|
+
htmlDocPtr doc;
|
12
13
|
|
13
14
|
rb_scan_args(argc, argv, "0*", &rest);
|
14
15
|
uri = rb_ary_entry(rest, (long)0);
|
15
16
|
external_id = rb_ary_entry(rest, (long)1);
|
16
17
|
|
17
|
-
|
18
|
+
doc = htmlNewDoc(
|
18
19
|
RTEST(uri) ? (const xmlChar *)StringValuePtr(uri) : NULL,
|
19
20
|
RTEST(external_id) ? (const xmlChar *)StringValuePtr(external_id) : NULL
|
20
21
|
);
|
@@ -39,11 +40,13 @@ static VALUE read_io( VALUE klass,
|
|
39
40
|
const char * c_url = NIL_P(url) ? NULL : StringValuePtr(url);
|
40
41
|
const char * c_enc = NIL_P(encoding) ? NULL : StringValuePtr(encoding);
|
41
42
|
VALUE error_list = rb_ary_new();
|
43
|
+
VALUE document;
|
44
|
+
htmlDocPtr doc;
|
42
45
|
|
43
46
|
xmlResetLastError();
|
44
47
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
45
48
|
|
46
|
-
|
49
|
+
doc = htmlReadIO(
|
47
50
|
io_read_callback,
|
48
51
|
io_close_callback,
|
49
52
|
(void *)io,
|
@@ -54,9 +57,11 @@ static VALUE read_io( VALUE klass,
|
|
54
57
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
55
58
|
|
56
59
|
if(doc == NULL) {
|
60
|
+
xmlErrorPtr error;
|
61
|
+
|
57
62
|
xmlFreeDoc(doc);
|
58
63
|
|
59
|
-
|
64
|
+
error = xmlGetLastError();
|
60
65
|
if(error)
|
61
66
|
rb_exc_raise(Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error));
|
62
67
|
else
|
@@ -65,7 +70,7 @@ static VALUE read_io( VALUE klass,
|
|
65
70
|
return Qnil;
|
66
71
|
}
|
67
72
|
|
68
|
-
|
73
|
+
document = Nokogiri_wrap_xml_document(klass, doc);
|
69
74
|
rb_iv_set(document, "@errors", error_list);
|
70
75
|
return document;
|
71
76
|
}
|
@@ -86,19 +91,23 @@ static VALUE read_memory( VALUE klass,
|
|
86
91
|
const char * c_buffer = StringValuePtr(string);
|
87
92
|
const char * c_url = NIL_P(url) ? NULL : StringValuePtr(url);
|
88
93
|
const char * c_enc = NIL_P(encoding) ? NULL : StringValuePtr(encoding);
|
89
|
-
int len = RSTRING_LEN(string);
|
94
|
+
int len = (int)RSTRING_LEN(string);
|
90
95
|
VALUE error_list = rb_ary_new();
|
96
|
+
VALUE document;
|
97
|
+
htmlDocPtr doc;
|
91
98
|
|
92
99
|
xmlResetLastError();
|
93
100
|
xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher);
|
94
101
|
|
95
|
-
|
102
|
+
doc = htmlReadMemory(c_buffer, len, c_url, c_enc, (int)NUM2INT(options));
|
96
103
|
xmlSetStructuredErrorFunc(NULL, NULL);
|
97
104
|
|
98
105
|
if(doc == NULL) {
|
106
|
+
xmlErrorPtr error;
|
107
|
+
|
99
108
|
xmlFreeDoc(doc);
|
100
109
|
|
101
|
-
|
110
|
+
error = xmlGetLastError();
|
102
111
|
if(error)
|
103
112
|
rb_exc_raise(Nokogiri_wrap_xml_syntax_error((VALUE)NULL, error));
|
104
113
|
else
|
@@ -107,7 +116,7 @@ static VALUE read_memory( VALUE klass,
|
|
107
116
|
return Qnil;
|
108
117
|
}
|
109
118
|
|
110
|
-
|
119
|
+
document = Nokogiri_wrap_xml_document(klass, doc);
|
111
120
|
rb_iv_set(document, "@errors", error_list);
|
112
121
|
return document;
|
113
122
|
}
|
@@ -9,16 +9,17 @@
|
|
9
9
|
static VALUE required_attributes(VALUE self)
|
10
10
|
{
|
11
11
|
htmlElemDesc * description;
|
12
|
+
VALUE list;
|
13
|
+
int i;
|
14
|
+
|
12
15
|
Data_Get_Struct(self, htmlElemDesc, description);
|
13
16
|
|
14
|
-
|
17
|
+
list = rb_ary_new();
|
15
18
|
|
16
19
|
if(NULL == description->attrs_req) return list;
|
17
20
|
|
18
|
-
|
19
|
-
while(description->attrs_req[i]) {
|
21
|
+
for(i = 0; description->attrs_depr[i]; i++) {
|
20
22
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_req[i]));
|
21
|
-
i++;
|
22
23
|
}
|
23
24
|
|
24
25
|
return list;
|
@@ -33,16 +34,17 @@ static VALUE required_attributes(VALUE self)
|
|
33
34
|
static VALUE deprecated_attributes(VALUE self)
|
34
35
|
{
|
35
36
|
htmlElemDesc * description;
|
37
|
+
VALUE list;
|
38
|
+
int i;
|
39
|
+
|
36
40
|
Data_Get_Struct(self, htmlElemDesc, description);
|
37
41
|
|
38
|
-
|
42
|
+
list = rb_ary_new();
|
39
43
|
|
40
44
|
if(NULL == description->attrs_depr) return list;
|
41
45
|
|
42
|
-
|
43
|
-
while(description->attrs_depr[i]) {
|
46
|
+
for(i = 0; description->attrs_depr[i]; i++) {
|
44
47
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_depr[i]));
|
45
|
-
i++;
|
46
48
|
}
|
47
49
|
|
48
50
|
return list;
|
@@ -57,16 +59,17 @@ static VALUE deprecated_attributes(VALUE self)
|
|
57
59
|
static VALUE optional_attributes(VALUE self)
|
58
60
|
{
|
59
61
|
htmlElemDesc * description;
|
62
|
+
VALUE list;
|
63
|
+
int i;
|
64
|
+
|
60
65
|
Data_Get_Struct(self, htmlElemDesc, description);
|
61
66
|
|
62
|
-
|
67
|
+
list = rb_ary_new();
|
63
68
|
|
64
69
|
if(NULL == description->attrs_opt) return list;
|
65
70
|
|
66
|
-
|
67
|
-
while(description->attrs_opt[i]) {
|
71
|
+
for(i = 0; description->attrs_opt[i]; i++) {
|
68
72
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(description->attrs_opt[i]));
|
69
|
-
i++;
|
70
73
|
}
|
71
74
|
|
72
75
|
return list;
|
@@ -95,16 +98,17 @@ static VALUE default_sub_element(VALUE self)
|
|
95
98
|
static VALUE sub_elements(VALUE self)
|
96
99
|
{
|
97
100
|
htmlElemDesc * description;
|
101
|
+
VALUE list;
|
102
|
+
int i;
|
103
|
+
|
98
104
|
Data_Get_Struct(self, htmlElemDesc, description);
|
99
105
|
|
100
|
-
|
106
|
+
list = rb_ary_new();
|
101
107
|
|
102
108
|
if(NULL == description->subelts) return list;
|
103
109
|
|
104
|
-
|
105
|
-
while(description->subelts[i]) {
|
110
|
+
for(i = 0; description->subelts[i]; i++) {
|
106
111
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(description->subelts[i]));
|
107
|
-
i++;
|
108
112
|
}
|
109
113
|
|
110
114
|
return list;
|
@@ -10,11 +10,11 @@ static VALUE get(VALUE self, VALUE key)
|
|
10
10
|
{
|
11
11
|
const htmlEntityDesc * desc =
|
12
12
|
htmlEntityLookup((const xmlChar *)StringValuePtr(key));
|
13
|
+
VALUE klass, args[3];
|
13
14
|
|
14
15
|
if(NULL == desc) return Qnil;
|
15
|
-
|
16
|
+
klass = rb_const_get(mNokogiriHtml, rb_intern("EntityDescription"));
|
16
17
|
|
17
|
-
VALUE args[3];
|
18
18
|
args[0] = INT2NUM((long)desc->value);
|
19
19
|
args[1] = NOKOGIRI_STR_NEW2(desc->name);
|
20
20
|
args[2] = NOKOGIRI_STR_NEW2(desc->desc);
|
@@ -15,19 +15,21 @@ static void deallocate(xmlParserCtxtPtr ctxt)
|
|
15
15
|
|
16
16
|
static VALUE parse_memory(VALUE klass, VALUE data, VALUE encoding)
|
17
17
|
{
|
18
|
+
htmlParserCtxtPtr ctxt;
|
19
|
+
|
18
20
|
if(NIL_P(data)) rb_raise(rb_eArgError, "data cannot be nil");
|
19
21
|
if(!(int)RSTRING_LEN(data))
|
20
22
|
rb_raise(rb_eRuntimeError, "data cannot be empty");
|
21
23
|
|
22
|
-
|
24
|
+
ctxt = htmlCreateMemoryParserCtxt(
|
23
25
|
StringValuePtr(data),
|
24
26
|
(int)RSTRING_LEN(data)
|
25
27
|
);
|
26
28
|
|
27
29
|
if(RTEST(encoding)) {
|
28
|
-
|
29
|
-
if(enc !=
|
30
|
-
|
30
|
+
xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler(StringValuePtr(encoding));
|
31
|
+
if(enc != NULL) {
|
32
|
+
xmlSwitchToEncoding(ctxt, enc);
|
31
33
|
if(ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
|
32
34
|
rb_raise(rb_eRuntimeError, "Unsupported encoding %s",
|
33
35
|
StringValuePtr(encoding));
|
@@ -49,16 +51,16 @@ static VALUE parse_file(VALUE klass, VALUE filename, VALUE encoding)
|
|
49
51
|
|
50
52
|
static VALUE parse_with(VALUE self, VALUE sax_handler)
|
51
53
|
{
|
54
|
+
htmlParserCtxtPtr ctxt;
|
55
|
+
htmlSAXHandlerPtr sax;
|
56
|
+
|
52
57
|
if(!rb_obj_is_kind_of(sax_handler, cNokogiriXmlSaxParser))
|
53
58
|
rb_raise(rb_eArgError, "argument must be a Nokogiri::XML::SAX::Parser");
|
54
59
|
|
55
|
-
htmlParserCtxtPtr ctxt;
|
56
60
|
Data_Get_Struct(self, htmlParserCtxt, ctxt);
|
57
|
-
|
58
|
-
htmlSAXHandlerPtr sax;
|
59
61
|
Data_Get_Struct(sax_handler, htmlSAXHandler, sax);
|
60
62
|
|
61
|
-
|
63
|
+
/* Free the sax handler since we'll assign our own */
|
62
64
|
if(ctxt->sax && ctxt->sax != (xmlSAXHandlerPtr)&xmlDefaultSAXHandler)
|
63
65
|
xmlFree(ctxt->sax);
|
64
66
|
|
data/ext/nokogiri/nokogiri.c
CHANGED
data/ext/nokogiri/nokogiri.h
CHANGED
@@ -2,8 +2,22 @@
|
|
2
2
|
#define NOKOGIRI_NATIVE
|
3
3
|
|
4
4
|
#include <stdlib.h>
|
5
|
+
#include <string.h>
|
5
6
|
#include <assert.h>
|
7
|
+
#include <stdarg.h>
|
8
|
+
|
9
|
+
#ifdef USE_INCLUDED_VASPRINTF
|
10
|
+
int vasprintf (char **strp, const char *fmt, va_list ap);
|
11
|
+
#else
|
12
|
+
|
13
|
+
#define _GNU_SOURCE
|
14
|
+
# include <stdio.h>
|
15
|
+
#undef _GNU_SOURCE
|
16
|
+
|
17
|
+
#endif
|
18
|
+
|
6
19
|
#include <libxml/parser.h>
|
20
|
+
#include <libxml/entities.h>
|
7
21
|
#include <libxml/parserInternals.h>
|
8
22
|
#include <libxml/xpath.h>
|
9
23
|
#include <libxml/xpathInternals.h>
|
@@ -15,16 +29,10 @@
|
|
15
29
|
#include <libxml/relaxng.h>
|
16
30
|
#include <ruby.h>
|
17
31
|
|
18
|
-
#ifdef
|
19
|
-
|
32
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
33
|
+
#include <ruby/st.h>
|
20
34
|
#else
|
21
|
-
|
22
|
-
#ifndef _GNU_SOURCE
|
23
|
-
#define _GNU_SOURCE
|
24
|
-
#endif
|
25
|
-
|
26
|
-
# include <stdio.h>
|
27
|
-
|
35
|
+
#include <st.h>
|
28
36
|
#endif
|
29
37
|
|
30
38
|
int is_2_6_16(void) ;
|
@@ -39,33 +47,31 @@ int is_2_6_16(void) ;
|
|
39
47
|
# endif
|
40
48
|
#endif
|
41
49
|
|
50
|
+
#ifndef NORETURN
|
51
|
+
# if defined(__GNUC__)
|
52
|
+
# define NORETURN(name) __attribute__((noreturn)) name
|
53
|
+
# else
|
54
|
+
# define NORETURN(name) name
|
55
|
+
# endif
|
56
|
+
#endif
|
57
|
+
|
42
58
|
#ifdef HAVE_RUBY_ENCODING_H
|
43
59
|
|
44
60
|
#include <ruby/encoding.h>
|
45
61
|
|
46
62
|
#define NOKOGIRI_STR_NEW2(str) \
|
47
|
-
(
|
48
|
-
VALUE _string = rb_str_new2((const char *)str); \
|
49
|
-
int _enc = rb_enc_find_index("UTF-8"); \
|
50
|
-
rb_enc_associate_index(_string, _enc); \
|
51
|
-
_string; \
|
52
|
-
})
|
63
|
+
NOKOGIRI_STR_NEW(str, strlen((const char *)(str)))
|
53
64
|
|
54
65
|
#define NOKOGIRI_STR_NEW(str, len) \
|
55
|
-
(
|
56
|
-
VALUE _string = rb_str_new((const char *)str, (long)len); \
|
57
|
-
int _enc = rb_enc_find_index("UTF-8"); \
|
58
|
-
rb_enc_associate_index(_string, _enc); \
|
59
|
-
_string; \
|
60
|
-
})
|
66
|
+
rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding())
|
61
67
|
|
62
68
|
#else
|
63
69
|
|
64
70
|
#define NOKOGIRI_STR_NEW2(str) \
|
65
|
-
rb_str_new2((const char *)str)
|
71
|
+
rb_str_new2((const char *)(str))
|
66
72
|
|
67
73
|
#define NOKOGIRI_STR_NEW(str, len) \
|
68
|
-
rb_str_new((const char *)str, (long)len)
|
74
|
+
rb_str_new((const char *)(str), (long)(len))
|
69
75
|
#endif
|
70
76
|
|
71
77
|
#define RBSTR_OR_QNIL(_str) \
|
@@ -84,7 +90,6 @@ int is_2_6_16(void) ;
|
|
84
90
|
#include <xml_document_fragment.h>
|
85
91
|
#include <xml_comment.h>
|
86
92
|
#include <xml_node_set.h>
|
87
|
-
#include <xml_xpath.h>
|
88
93
|
#include <xml_dtd.h>
|
89
94
|
#include <xml_attribute_decl.h>
|
90
95
|
#include <xml_element_decl.h>
|
@@ -112,10 +117,10 @@ extern VALUE mNokogiriHtmlSax ;
|
|
112
117
|
extern VALUE mNokogiriXslt ;
|
113
118
|
|
114
119
|
#define NOKOGIRI_ROOT_NODE(_node) \
|
115
|
-
(
|
116
|
-
|
117
|
-
|
118
|
-
|
120
|
+
st_insert(((nokogiriTuplePtr)(_node)->doc->_private)->unlinkedNodes, (st_data_t)(_node), (st_data_t)(_node))
|
121
|
+
|
122
|
+
#define NOKOGIRI_ROOT_NSDEF(_nsDef, _doc) \
|
123
|
+
st_insert(((nokogiriTuplePtr)(_doc)->_private)->unlinkedNodes, (st_data_t)(_nsDef), (st_data_t)(_nsDef))
|
119
124
|
|
120
125
|
#ifdef DEBUG
|
121
126
|
|
data/ext/nokogiri/xml_attr.c
CHANGED
@@ -19,21 +19,21 @@ static VALUE set_value(VALUE self, VALUE content)
|
|
19
19
|
xmlChar *buffer;
|
20
20
|
xmlNode *tmp;
|
21
21
|
|
22
|
-
|
22
|
+
/* Encode our content */
|
23
23
|
buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValuePtr(content));
|
24
24
|
|
25
25
|
attr->children = xmlStringGetNodeList(attr->doc, buffer);
|
26
26
|
attr->last = NULL;
|
27
27
|
tmp = attr->children;
|
28
28
|
|
29
|
-
|
29
|
+
/* Loop through the children */
|
30
30
|
for(tmp = attr->children; tmp; tmp = tmp->next) {
|
31
31
|
tmp->parent = (xmlNode *)attr;
|
32
32
|
tmp->doc = attr->doc;
|
33
33
|
if(tmp->next == NULL) attr->last = tmp;
|
34
34
|
}
|
35
35
|
|
36
|
-
|
36
|
+
/* Free up memory */
|
37
37
|
xmlFree(buffer);
|
38
38
|
}
|
39
39
|
|
@@ -52,12 +52,14 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
52
52
|
VALUE document;
|
53
53
|
VALUE name;
|
54
54
|
VALUE rest;
|
55
|
+
xmlAttrPtr node;
|
56
|
+
VALUE rb_node;
|
55
57
|
|
56
58
|
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
57
59
|
|
58
60
|
Data_Get_Struct(document, xmlDoc, xml_doc);
|
59
61
|
|
60
|
-
|
62
|
+
node = xmlNewDocProp(
|
61
63
|
xml_doc,
|
62
64
|
(const xmlChar *)StringValuePtr(name),
|
63
65
|
NULL
|
@@ -65,7 +67,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
65
67
|
|
66
68
|
NOKOGIRI_ROOT_NODE((xmlNodePtr)node);
|
67
69
|
|
68
|
-
|
70
|
+
rb_node = Nokogiri_wrap_xml_node(klass, (xmlNodePtr)node);
|
69
71
|
rb_obj_call_init(rb_node, argc, argv);
|
70
72
|
|
71
73
|
if(rb_block_given_p()) rb_yield(rb_node);
|
@@ -37,10 +37,13 @@ static VALUE default_value(VALUE self)
|
|
37
37
|
static VALUE enumeration(VALUE self)
|
38
38
|
{
|
39
39
|
xmlAttributePtr node;
|
40
|
+
xmlEnumerationPtr enm;
|
41
|
+
VALUE list;
|
42
|
+
|
40
43
|
Data_Get_Struct(self, xmlAttribute, node);
|
41
44
|
|
42
|
-
|
43
|
-
|
45
|
+
list = rb_ary_new();
|
46
|
+
enm = node->tree;
|
44
47
|
|
45
48
|
while(enm) {
|
46
49
|
rb_ary_push(list, NOKOGIRI_STR_NEW2(enm->name));
|
data/ext/nokogiri/xml_cdata.c
CHANGED
@@ -9,15 +9,17 @@
|
|
9
9
|
static VALUE new(int argc, VALUE *argv, VALUE klass)
|
10
10
|
{
|
11
11
|
xmlDocPtr xml_doc;
|
12
|
+
xmlNodePtr node;
|
12
13
|
VALUE doc;
|
13
14
|
VALUE content;
|
14
15
|
VALUE rest;
|
16
|
+
VALUE rb_node;
|
15
17
|
|
16
18
|
rb_scan_args(argc, argv, "2*", &doc, &content, &rest);
|
17
19
|
|
18
20
|
Data_Get_Struct(doc, xmlDoc, xml_doc);
|
19
21
|
|
20
|
-
|
22
|
+
node = xmlNewCDataBlock(
|
21
23
|
xml_doc->doc,
|
22
24
|
NIL_P(content) ? NULL : (const xmlChar *)StringValuePtr(content),
|
23
25
|
NIL_P(content) ? 0 : (int)RSTRING_LEN(content)
|
@@ -25,7 +27,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
|
|
25
27
|
|
26
28
|
NOKOGIRI_ROOT_NODE(node);
|
27
29
|
|
28
|
-
|
30
|
+
rb_node = Nokogiri_wrap_xml_node(klass, node);
|
29
31
|
rb_obj_call_init(rb_node, argc, argv);
|
30
32
|
|
31
33
|
if(rb_block_given_p()) rb_yield(rb_node);
|