nokogiri 1.13.8 → 1.15.7
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.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +40 -0
- data/LICENSE-DEPENDENCIES.md +830 -509
- data/LICENSE.md +1 -1
- data/README.md +18 -11
- data/dependencies.yml +33 -15
- data/ext/nokogiri/extconf.rb +164 -46
- data/ext/nokogiri/gumbo.c +20 -10
- data/ext/nokogiri/html4_document.c +3 -4
- data/ext/nokogiri/html4_element_description.c +20 -15
- data/ext/nokogiri/html4_entity_lookup.c +2 -2
- data/ext/nokogiri/html4_sax_parser_context.c +11 -22
- data/ext/nokogiri/html4_sax_push_parser.c +3 -3
- data/ext/nokogiri/nokogiri.c +84 -75
- data/ext/nokogiri/nokogiri.h +31 -16
- data/ext/nokogiri/test_global_handlers.c +1 -1
- data/ext/nokogiri/xml_attr.c +2 -2
- data/ext/nokogiri/xml_attribute_decl.c +2 -2
- data/ext/nokogiri/xml_cdata.c +32 -18
- data/ext/nokogiri/xml_comment.c +2 -2
- data/ext/nokogiri/xml_document.c +127 -34
- data/ext/nokogiri/xml_document_fragment.c +2 -2
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_element_content.c +34 -31
- data/ext/nokogiri/xml_element_decl.c +7 -7
- data/ext/nokogiri/xml_encoding_handler.c +15 -7
- data/ext/nokogiri/xml_entity_decl.c +1 -1
- data/ext/nokogiri/xml_entity_reference.c +2 -2
- data/ext/nokogiri/xml_namespace.c +79 -14
- data/ext/nokogiri/xml_node.c +300 -34
- data/ext/nokogiri/xml_node_set.c +125 -107
- data/ext/nokogiri/xml_processing_instruction.c +2 -2
- data/ext/nokogiri/xml_reader.c +81 -48
- data/ext/nokogiri/xml_relax_ng.c +66 -81
- data/ext/nokogiri/xml_sax_parser.c +45 -20
- data/ext/nokogiri/xml_sax_parser_context.c +46 -30
- data/ext/nokogiri/xml_sax_push_parser.c +30 -11
- data/ext/nokogiri/xml_schema.c +95 -117
- data/ext/nokogiri/xml_syntax_error.c +1 -1
- data/ext/nokogiri/xml_text.c +28 -14
- data/ext/nokogiri/xml_xpath_context.c +216 -136
- data/ext/nokogiri/xslt_stylesheet.c +118 -64
- data/gumbo-parser/Makefile +10 -0
- data/gumbo-parser/src/attribute.h +1 -1
- data/gumbo-parser/src/error.c +10 -6
- data/gumbo-parser/src/error.h +1 -1
- data/gumbo-parser/src/foreign_attrs.c +15 -16
- data/gumbo-parser/src/foreign_attrs.gperf +1 -1
- data/gumbo-parser/src/{gumbo.h → nokogiri_gumbo.h} +1 -0
- data/gumbo-parser/src/parser.c +21 -5
- data/gumbo-parser/src/replacement.h +1 -1
- data/gumbo-parser/src/string_buffer.h +1 -1
- data/gumbo-parser/src/string_piece.c +1 -1
- data/gumbo-parser/src/svg_attrs.c +2 -2
- data/gumbo-parser/src/svg_tags.c +2 -2
- data/gumbo-parser/src/tag.c +2 -1
- data/gumbo-parser/src/tag_lookup.c +7 -7
- data/gumbo-parser/src/tag_lookup.gperf +1 -0
- data/gumbo-parser/src/tag_lookup.h +1 -1
- data/gumbo-parser/src/token_buffer.h +1 -1
- data/gumbo-parser/src/tokenizer.c +1 -1
- data/gumbo-parser/src/tokenizer.h +1 -1
- data/gumbo-parser/src/utf8.c +1 -1
- data/gumbo-parser/src/utf8.h +1 -1
- data/gumbo-parser/src/util.c +1 -3
- data/gumbo-parser/src/util.h +4 -0
- data/gumbo-parser/src/vector.h +1 -1
- data/lib/nokogiri/css/node.rb +2 -2
- data/lib/nokogiri/css/xpath_visitor.rb +7 -5
- data/lib/nokogiri/css.rb +6 -0
- data/lib/nokogiri/decorators/slop.rb +1 -1
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +4 -3
- data/lib/nokogiri/html4/document.rb +2 -121
- data/lib/nokogiri/html4/document_fragment.rb +1 -1
- data/lib/nokogiri/html4/element_description_defaults.rb +1827 -365
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4.rb +1 -0
- data/lib/nokogiri/html5/document.rb +113 -36
- data/lib/nokogiri/html5/document_fragment.rb +10 -3
- data/lib/nokogiri/html5/node.rb +8 -5
- data/lib/nokogiri/html5.rb +130 -216
- data/lib/nokogiri/jruby/dependencies.rb +1 -19
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/version/constant.rb +1 -1
- data/lib/nokogiri/version/info.rb +11 -10
- data/lib/nokogiri/xml/attr.rb +49 -0
- data/lib/nokogiri/xml/attribute_decl.rb +4 -2
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +102 -55
- data/lib/nokogiri/xml/document_fragment.rb +50 -7
- data/lib/nokogiri/xml/element_content.rb +10 -2
- data/lib/nokogiri/xml/element_decl.rb +4 -2
- data/lib/nokogiri/xml/entity_decl.rb +4 -2
- data/lib/nokogiri/xml/namespace.rb +42 -0
- data/lib/nokogiri/xml/node/save_options.rb +14 -4
- data/lib/nokogiri/xml/node.rb +212 -48
- data/lib/nokogiri/xml/node_set.rb +88 -9
- data/lib/nokogiri/xml/parse_options.rb +129 -50
- data/lib/nokogiri/xml/pp/node.rb +28 -15
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/sax/document.rb +1 -1
- data/lib/nokogiri/xml/sax/parser.rb +2 -3
- data/lib/nokogiri/xml/searchable.rb +18 -10
- data/lib/nokogiri/xslt.rb +74 -4
- data/lib/nokogiri.rb +15 -15
- data/lib/xsd/xmlparser/nokogiri.rb +4 -2
- data/patches/libxml2/0010-update-config.guess-and-config.sub-for-libxml2.patch +224 -0
- data/patches/libxml2/0011-rip-out-libxml2-s-libc_single_threaded-support.patch +30 -0
- data/patches/libxslt/0001-update-config.guess-and-config.sub-for-libxslt.patch +224 -0
- data/ports/archives/libxml2-2.11.7.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.39.tar.xz +0 -0
- metadata +19 -242
- data/patches/libxml2/0004-use-glibc-strlen.patch +0 -53
- data/patches/libxml2/0005-avoid-isnan-isinf.patch +0 -81
- data/patches/libxml2/0006-update-automake-files-for-arm64.patch +0 -3040
- data/patches/libxml2/0008-htmlParseComment-handle-abruptly-closed-comments.patch +0 -61
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +0 -3037
- data/ports/archives/libxml2-2.9.14.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.35.tar.xz +0 -0
@@ -2,17 +2,22 @@
|
|
2
2
|
|
3
3
|
VALUE cNokogiriXmlElementContent;
|
4
4
|
|
5
|
+
static const rb_data_type_t element_content_data_type = {
|
6
|
+
.wrap_struct_name = "Nokogiri::XML::ElementContent",
|
7
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
8
|
+
};
|
9
|
+
|
5
10
|
/*
|
6
11
|
* call-seq:
|
7
|
-
*
|
12
|
+
* name → String
|
8
13
|
*
|
9
|
-
*
|
14
|
+
* [Returns] The content element's +name+
|
10
15
|
*/
|
11
16
|
static VALUE
|
12
17
|
get_name(VALUE self)
|
13
18
|
{
|
14
19
|
xmlElementContentPtr elem;
|
15
|
-
|
20
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
16
21
|
|
17
22
|
if (!elem->name) { return Qnil; }
|
18
23
|
return NOKOGIRI_STR_NEW2(elem->name);
|
@@ -20,47 +25,40 @@ get_name(VALUE self)
|
|
20
25
|
|
21
26
|
/*
|
22
27
|
* call-seq:
|
23
|
-
*
|
28
|
+
* type → Integer
|
24
29
|
*
|
25
|
-
*
|
26
|
-
* or OR.
|
30
|
+
* [Returns] The content element's +type+. Possible values are +PCDATA+, +ELEMENT+, +SEQ+, or +OR+.
|
27
31
|
*/
|
28
32
|
static VALUE
|
29
33
|
get_type(VALUE self)
|
30
34
|
{
|
31
35
|
xmlElementContentPtr elem;
|
32
|
-
|
36
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
33
37
|
|
34
|
-
return INT2NUM(
|
38
|
+
return INT2NUM(elem->type);
|
35
39
|
}
|
36
40
|
|
37
41
|
/*
|
38
|
-
* call-seq:
|
39
|
-
* c1
|
40
|
-
*
|
41
42
|
* Get the first child.
|
42
43
|
*/
|
43
44
|
static VALUE
|
44
45
|
get_c1(VALUE self)
|
45
46
|
{
|
46
47
|
xmlElementContentPtr elem;
|
47
|
-
|
48
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
48
49
|
|
49
50
|
if (!elem->c1) { return Qnil; }
|
50
51
|
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c1);
|
51
52
|
}
|
52
53
|
|
53
54
|
/*
|
54
|
-
*
|
55
|
-
* c2
|
56
|
-
*
|
57
|
-
* Get the first child.
|
55
|
+
* Get the second child.
|
58
56
|
*/
|
59
57
|
static VALUE
|
60
58
|
get_c2(VALUE self)
|
61
59
|
{
|
62
60
|
xmlElementContentPtr elem;
|
63
|
-
|
61
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
64
62
|
|
65
63
|
if (!elem->c2) { return Qnil; }
|
66
64
|
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c2);
|
@@ -68,51 +66,56 @@ get_c2(VALUE self)
|
|
68
66
|
|
69
67
|
/*
|
70
68
|
* call-seq:
|
71
|
-
*
|
69
|
+
* occur → Integer
|
72
70
|
*
|
73
|
-
*
|
74
|
-
* or PLUS.
|
71
|
+
* [Returns] The content element's +occur+ flag. Possible values are +ONCE+, +OPT+, +MULT+ or +PLUS+.
|
75
72
|
*/
|
76
73
|
static VALUE
|
77
74
|
get_occur(VALUE self)
|
78
75
|
{
|
79
76
|
xmlElementContentPtr elem;
|
80
|
-
|
77
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
81
78
|
|
82
|
-
return INT2NUM(
|
79
|
+
return INT2NUM(elem->ocur);
|
83
80
|
}
|
84
81
|
|
85
82
|
/*
|
86
83
|
* call-seq:
|
87
|
-
*
|
84
|
+
* prefix → String
|
88
85
|
*
|
89
|
-
*
|
86
|
+
* [Returns] The content element's namespace +prefix+.
|
90
87
|
*/
|
91
88
|
static VALUE
|
92
89
|
get_prefix(VALUE self)
|
93
90
|
{
|
94
91
|
xmlElementContentPtr elem;
|
95
|
-
|
92
|
+
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
|
96
93
|
|
97
94
|
if (!elem->prefix) { return Qnil; }
|
98
95
|
|
99
96
|
return NOKOGIRI_STR_NEW2(elem->prefix);
|
100
97
|
}
|
101
98
|
|
99
|
+
/*
|
100
|
+
* create a Nokogiri::XML::ElementContent object around an +element+.
|
101
|
+
*/
|
102
102
|
VALUE
|
103
|
-
noko_xml_element_content_wrap(VALUE
|
103
|
+
noko_xml_element_content_wrap(VALUE rb_document, xmlElementContentPtr c_element_content)
|
104
104
|
{
|
105
|
-
VALUE elem =
|
105
|
+
VALUE elem = TypedData_Wrap_Struct(
|
106
|
+
cNokogiriXmlElementContent,
|
107
|
+
&element_content_data_type,
|
108
|
+
c_element_content
|
109
|
+
);
|
106
110
|
|
107
|
-
/*
|
108
|
-
|
109
|
-
rb_iv_set(elem, "@document", doc);
|
111
|
+
/* keep a handle on the document for GC marking */
|
112
|
+
rb_iv_set(elem, "@document", rb_document);
|
110
113
|
|
111
114
|
return elem;
|
112
115
|
}
|
113
116
|
|
114
117
|
void
|
115
|
-
noko_init_xml_element_content()
|
118
|
+
noko_init_xml_element_content(void)
|
116
119
|
{
|
117
120
|
cNokogiriXmlElementContent = rb_define_class_under(mNokogiriXml, "ElementContent", rb_cObject);
|
118
121
|
|
@@ -6,7 +6,7 @@ static ID id_document;
|
|
6
6
|
|
7
7
|
/*
|
8
8
|
* call-seq:
|
9
|
-
*
|
9
|
+
* element_type → Integer
|
10
10
|
*
|
11
11
|
* The element_type
|
12
12
|
*/
|
@@ -15,14 +15,14 @@ element_type(VALUE self)
|
|
15
15
|
{
|
16
16
|
xmlElementPtr node;
|
17
17
|
Noko_Node_Get_Struct(self, xmlElement, node);
|
18
|
-
return INT2NUM(
|
18
|
+
return INT2NUM(node->etype);
|
19
19
|
}
|
20
20
|
|
21
21
|
/*
|
22
22
|
* call-seq:
|
23
|
-
*
|
23
|
+
* content → Nokogiri::XML::ElementContent
|
24
24
|
*
|
25
|
-
* The
|
25
|
+
* [Returns] The root of this element declaration's content tree.
|
26
26
|
*/
|
27
27
|
static VALUE
|
28
28
|
content(VALUE self)
|
@@ -40,9 +40,9 @@ content(VALUE self)
|
|
40
40
|
|
41
41
|
/*
|
42
42
|
* call-seq:
|
43
|
-
*
|
43
|
+
* prefix → String
|
44
44
|
*
|
45
|
-
* The namespace prefix for this
|
45
|
+
* [Returns] The namespace +prefix+ for this element declaration.
|
46
46
|
*/
|
47
47
|
static VALUE
|
48
48
|
prefix(VALUE self)
|
@@ -56,7 +56,7 @@ prefix(VALUE self)
|
|
56
56
|
}
|
57
57
|
|
58
58
|
void
|
59
|
-
noko_init_xml_element_decl()
|
59
|
+
noko_init_xml_element_decl(void)
|
60
60
|
{
|
61
61
|
assert(cNokogiriXmlNode);
|
62
62
|
cNokogiriXmlElementDecl = rb_define_class_under(mNokogiriXml, "ElementDecl", cNokogiriXmlNode);
|
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
VALUE cNokogiriEncodingHandler;
|
4
4
|
|
5
|
-
|
6
5
|
static void
|
7
|
-
|
6
|
+
xml_encoding_handler_dealloc(void *data)
|
8
7
|
{
|
9
8
|
/* make sure iconv handlers are cleaned up and freed */
|
9
|
+
xmlCharEncodingHandlerPtr c_handler = data;
|
10
10
|
xmlCharEncCloseFunc(c_handler);
|
11
11
|
}
|
12
12
|
|
13
|
+
static const rb_data_type_t xml_encoding_handler_type = {
|
14
|
+
.wrap_struct_name = "Nokogiri::EncodingHandler",
|
15
|
+
.function = {
|
16
|
+
.dfree = xml_encoding_handler_dealloc,
|
17
|
+
},
|
18
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
19
|
+
};
|
20
|
+
|
13
21
|
|
14
22
|
/*
|
15
23
|
* call-seq: Nokogiri::EncodingHandler.[](name)
|
@@ -23,7 +31,7 @@ rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
|
|
23
31
|
|
24
32
|
handler = xmlFindCharEncodingHandler(StringValueCStr(key));
|
25
33
|
if (handler) {
|
26
|
-
return
|
34
|
+
return TypedData_Wrap_Struct(klass, &xml_encoding_handler_type, handler);
|
27
35
|
}
|
28
36
|
|
29
37
|
return Qnil;
|
@@ -45,9 +53,9 @@ rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
|
|
45
53
|
|
46
54
|
|
47
55
|
/*
|
48
|
-
* call-seq: Nokogiri::EncodingHandler.alias(
|
56
|
+
* call-seq: Nokogiri::EncodingHandler.alias(real_name, alias_name)
|
49
57
|
*
|
50
|
-
* Alias encoding handler with name +
|
58
|
+
* Alias encoding handler with name +real_name+ to name +alias_name+
|
51
59
|
*/
|
52
60
|
static VALUE
|
53
61
|
rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
|
@@ -82,14 +90,14 @@ rb_xml_encoding_handler_name(VALUE self)
|
|
82
90
|
{
|
83
91
|
xmlCharEncodingHandlerPtr handler;
|
84
92
|
|
85
|
-
|
93
|
+
TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_encoding_handler_type, handler);
|
86
94
|
|
87
95
|
return NOKOGIRI_STR_NEW2(handler->name);
|
88
96
|
}
|
89
97
|
|
90
98
|
|
91
99
|
void
|
92
|
-
noko_init_xml_encoding_handler()
|
100
|
+
noko_init_xml_encoding_handler(void)
|
93
101
|
{
|
94
102
|
cNokogiriEncodingHandler = rb_define_class_under(mNokogiri, "EncodingHandler", rb_cObject);
|
95
103
|
|
@@ -20,7 +20,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
20
20
|
|
21
21
|
rb_scan_args(argc, argv, "2*", &document, &name, &rest);
|
22
22
|
|
23
|
-
|
23
|
+
xml_doc = noko_xml_document_unwrap(document);
|
24
24
|
|
25
25
|
node = xmlNewReference(
|
26
26
|
xml_doc,
|
@@ -38,7 +38,7 @@ new (int argc, VALUE *argv, VALUE klass)
|
|
38
38
|
}
|
39
39
|
|
40
40
|
void
|
41
|
-
noko_init_xml_entity_reference()
|
41
|
+
noko_init_xml_entity_reference(void)
|
42
42
|
{
|
43
43
|
assert(cNokogiriXmlNode);
|
44
44
|
/*
|
@@ -25,13 +25,14 @@
|
|
25
25
|
VALUE cNokogiriXmlNamespace ;
|
26
26
|
|
27
27
|
static void
|
28
|
-
|
28
|
+
_xml_namespace_dealloc(void *ptr)
|
29
29
|
{
|
30
30
|
/*
|
31
31
|
* this deallocator is only used for namespace nodes that are part of an xpath
|
32
32
|
* node set. see noko_xml_namespace_wrap().
|
33
33
|
*/
|
34
|
-
|
34
|
+
xmlNsPtr ns = ptr;
|
35
|
+
|
35
36
|
if (ns->href) {
|
36
37
|
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(ns->href));
|
37
38
|
}
|
@@ -39,39 +40,99 @@ dealloc_namespace(xmlNsPtr ns)
|
|
39
40
|
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(ns->prefix));
|
40
41
|
}
|
41
42
|
xmlFree(ns);
|
42
|
-
NOKOGIRI_DEBUG_END(ns) ;
|
43
43
|
}
|
44
44
|
|
45
|
+
#ifdef HAVE_RB_GC_LOCATION
|
46
|
+
static void
|
47
|
+
_xml_namespace_update_references(void *ptr)
|
48
|
+
{
|
49
|
+
xmlNsPtr ns = ptr;
|
50
|
+
if (ns->_private) {
|
51
|
+
ns->_private = (void *)rb_gc_location((VALUE)ns->_private);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
#else
|
55
|
+
# define _xml_namespace_update_references 0
|
56
|
+
#endif
|
57
|
+
|
58
|
+
static const rb_data_type_t nokogiri_xml_namespace_type_with_dealloc = {
|
59
|
+
.wrap_struct_name = "Nokogiri::XML::Namespace#with_dealloc",
|
60
|
+
.function = {
|
61
|
+
.dfree = _xml_namespace_dealloc,
|
62
|
+
.dcompact = _xml_namespace_update_references,
|
63
|
+
},
|
64
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
65
|
+
};
|
66
|
+
|
67
|
+
static const rb_data_type_t nokogiri_xml_namespace_type_without_dealloc = {
|
68
|
+
.wrap_struct_name = "Nokogiri::XML::Namespace#without_dealloc",
|
69
|
+
.function = {
|
70
|
+
.dcompact = _xml_namespace_update_references,
|
71
|
+
},
|
72
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
73
|
+
};
|
45
74
|
|
46
75
|
/*
|
47
|
-
*
|
48
|
-
*
|
76
|
+
* :call-seq:
|
77
|
+
* prefix() → String or nil
|
78
|
+
*
|
79
|
+
* Return the prefix for this Namespace, or +nil+ if there is no prefix (e.g., default namespace).
|
80
|
+
*
|
81
|
+
* *Example*
|
49
82
|
*
|
50
|
-
*
|
83
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
84
|
+
* <?xml version="1.0"?>
|
85
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
86
|
+
* <child1 foo="abc" noko:bar="def"/>
|
87
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
88
|
+
* </root>
|
89
|
+
* XML
|
90
|
+
*
|
91
|
+
* doc.root.elements.first.namespace.prefix
|
92
|
+
* # => nil
|
93
|
+
*
|
94
|
+
* doc.root.elements.last.namespace.prefix
|
95
|
+
* # => "noko"
|
51
96
|
*/
|
52
97
|
static VALUE
|
53
98
|
prefix(VALUE self)
|
54
99
|
{
|
55
100
|
xmlNsPtr ns;
|
56
101
|
|
57
|
-
|
102
|
+
Noko_Namespace_Get_Struct(self, xmlNs, ns);
|
58
103
|
if (!ns->prefix) { return Qnil; }
|
59
104
|
|
60
105
|
return NOKOGIRI_STR_NEW2(ns->prefix);
|
61
106
|
}
|
62
107
|
|
63
108
|
/*
|
64
|
-
*
|
65
|
-
*
|
109
|
+
* :call-seq:
|
110
|
+
* href() → String
|
111
|
+
*
|
112
|
+
* Returns the URI reference for this Namespace.
|
113
|
+
*
|
114
|
+
* *Example*
|
115
|
+
*
|
116
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
117
|
+
* <?xml version="1.0"?>
|
118
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
119
|
+
* <child1 foo="abc" noko:bar="def"/>
|
120
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
121
|
+
* </root>
|
122
|
+
* XML
|
123
|
+
*
|
124
|
+
* doc.root.elements.first.namespace.href
|
125
|
+
* # => "http://nokogiri.org/ns/default"
|
66
126
|
*
|
67
|
-
*
|
127
|
+
* doc.root.elements.last.namespace.href
|
128
|
+
* # => "http://nokogiri.org/ns/noko"
|
68
129
|
*/
|
69
130
|
static VALUE
|
70
131
|
href(VALUE self)
|
71
132
|
{
|
72
133
|
xmlNsPtr ns;
|
73
134
|
|
74
|
-
|
135
|
+
Noko_Namespace_Get_Struct(self, xmlNs, ns);
|
75
136
|
if (!ns->href) { return Qnil; }
|
76
137
|
|
77
138
|
return NOKOGIRI_STR_NEW2(ns->href);
|
@@ -87,14 +148,18 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
|
|
87
148
|
}
|
88
149
|
|
89
150
|
if (c_document) {
|
90
|
-
rb_namespace =
|
151
|
+
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
152
|
+
&nokogiri_xml_namespace_type_without_dealloc,
|
153
|
+
c_namespace);
|
91
154
|
|
92
155
|
if (DOC_RUBY_OBJECT_TEST(c_document)) {
|
93
156
|
rb_iv_set(rb_namespace, "@document", DOC_RUBY_OBJECT(c_document));
|
94
157
|
rb_ary_push(DOC_NODE_CACHE(c_document), rb_namespace);
|
95
158
|
}
|
96
159
|
} else {
|
97
|
-
rb_namespace =
|
160
|
+
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
161
|
+
&nokogiri_xml_namespace_type_with_dealloc,
|
162
|
+
c_namespace);
|
98
163
|
}
|
99
164
|
|
100
165
|
c_namespace->_private = (void *)rb_namespace;
|
@@ -109,7 +174,7 @@ noko_xml_namespace_wrap_xpath_copy(xmlNsPtr c_namespace)
|
|
109
174
|
}
|
110
175
|
|
111
176
|
void
|
112
|
-
noko_init_xml_namespace()
|
177
|
+
noko_init_xml_namespace(void)
|
113
178
|
{
|
114
179
|
cNokogiriXmlNamespace = rb_define_class_under(mNokogiriXml, "Namespace", rb_cObject);
|
115
180
|
|