nokogiri 1.12.5 → 1.14.3
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.
- checksums.yaml +4 -4
- data/Gemfile +41 -0
- data/LICENSE-DEPENDENCIES.md +830 -509
- data/LICENSE.md +1 -1
- data/README.md +23 -14
- data/bin/nokogiri +63 -50
- data/dependencies.yml +33 -66
- data/ext/nokogiri/extconf.rb +159 -63
- data/ext/nokogiri/gumbo.c +21 -11
- data/ext/nokogiri/html4_document.c +2 -2
- data/ext/nokogiri/html4_element_description.c +1 -1
- data/ext/nokogiri/html4_entity_lookup.c +2 -2
- data/ext/nokogiri/html4_sax_parser_context.c +3 -9
- data/ext/nokogiri/html4_sax_push_parser.c +1 -1
- data/ext/nokogiri/nokogiri.c +38 -51
- data/ext/nokogiri/nokogiri.h +26 -14
- data/ext/nokogiri/test_global_handlers.c +1 -1
- data/ext/nokogiri/xml_attr.c +3 -3
- data/ext/nokogiri/xml_attribute_decl.c +5 -5
- data/ext/nokogiri/xml_cdata.c +3 -3
- data/ext/nokogiri/xml_comment.c +1 -1
- data/ext/nokogiri/xml_document.c +53 -44
- data/ext/nokogiri/xml_document_fragment.c +1 -3
- data/ext/nokogiri/xml_dtd.c +11 -11
- data/ext/nokogiri/xml_element_content.c +3 -3
- data/ext/nokogiri/xml_element_decl.c +5 -5
- data/ext/nokogiri/xml_encoding_handler.c +28 -14
- data/ext/nokogiri/xml_entity_decl.c +6 -6
- data/ext/nokogiri/xml_entity_reference.c +1 -1
- data/ext/nokogiri/xml_namespace.c +80 -14
- data/ext/nokogiri/xml_node.c +982 -396
- data/ext/nokogiri/xml_node_set.c +4 -6
- data/ext/nokogiri/xml_processing_instruction.c +1 -1
- data/ext/nokogiri/xml_reader.c +133 -32
- data/ext/nokogiri/xml_relax_ng.c +1 -3
- data/ext/nokogiri/xml_sax_parser.c +23 -17
- data/ext/nokogiri/xml_sax_parser_context.c +11 -9
- data/ext/nokogiri/xml_sax_push_parser.c +1 -3
- data/ext/nokogiri/xml_schema.c +4 -6
- data/ext/nokogiri/xml_syntax_error.c +1 -1
- data/ext/nokogiri/xml_text.c +2 -2
- data/ext/nokogiri/xml_xpath_context.c +144 -114
- data/ext/nokogiri/xslt_stylesheet.c +122 -23
- data/gumbo-parser/Makefile +10 -0
- data/gumbo-parser/src/attribute.h +1 -1
- data/gumbo-parser/src/error.c +2 -2
- data/gumbo-parser/src/error.h +1 -1
- data/gumbo-parser/src/foreign_attrs.c +2 -2
- data/gumbo-parser/src/{gumbo.h → nokogiri_gumbo.h} +1 -0
- data/gumbo-parser/src/parser.c +8 -16
- 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/class_resolver.rb +67 -0
- data/lib/nokogiri/css/node.rb +9 -8
- data/lib/nokogiri/css/parser.rb +360 -341
- data/lib/nokogiri/css/parser.y +249 -244
- data/lib/nokogiri/css/parser_extras.rb +22 -20
- data/lib/nokogiri/css/syntax_error.rb +1 -0
- data/lib/nokogiri/css/tokenizer.rb +4 -3
- data/lib/nokogiri/css/tokenizer.rex +3 -2
- data/lib/nokogiri/css/xpath_visitor.rb +184 -85
- data/lib/nokogiri/css.rb +44 -6
- data/lib/nokogiri/decorators/slop.rb +8 -7
- data/lib/nokogiri/encoding_handler.rb +57 -0
- data/lib/nokogiri/extension.rb +4 -3
- data/lib/nokogiri/gumbo.rb +1 -0
- data/lib/nokogiri/html.rb +16 -10
- data/lib/nokogiri/html4/builder.rb +1 -0
- data/lib/nokogiri/html4/document.rb +56 -164
- data/lib/nokogiri/html4/document_fragment.rb +11 -7
- data/lib/nokogiri/html4/element_description.rb +1 -0
- data/lib/nokogiri/html4/element_description_defaults.rb +432 -532
- data/lib/nokogiri/html4/encoding_reader.rb +121 -0
- data/lib/nokogiri/html4/entity_lookup.rb +2 -1
- data/lib/nokogiri/html4/sax/parser.rb +5 -2
- data/lib/nokogiri/html4/sax/parser_context.rb +1 -0
- data/lib/nokogiri/html4/sax/push_parser.rb +7 -7
- data/lib/nokogiri/html4.rb +12 -5
- data/lib/nokogiri/html5/document.rb +126 -32
- data/lib/nokogiri/html5/document_fragment.rb +14 -4
- data/lib/nokogiri/html5/node.rb +12 -7
- data/lib/nokogiri/html5.rb +138 -222
- data/lib/nokogiri/jruby/dependencies.rb +2 -19
- data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
- data/lib/nokogiri/syntax_error.rb +1 -0
- data/lib/nokogiri/version/constant.rb +2 -1
- data/lib/nokogiri/version/info.rb +32 -24
- data/lib/nokogiri/version.rb +1 -0
- data/lib/nokogiri/xml/attr.rb +54 -3
- data/lib/nokogiri/xml/attribute_decl.rb +2 -1
- data/lib/nokogiri/xml/builder.rb +35 -33
- data/lib/nokogiri/xml/cdata.rb +2 -1
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +232 -143
- data/lib/nokogiri/xml/document_fragment.rb +88 -42
- data/lib/nokogiri/xml/dtd.rb +3 -2
- data/lib/nokogiri/xml/element_content.rb +1 -0
- data/lib/nokogiri/xml/element_decl.rb +2 -1
- data/lib/nokogiri/xml/entity_decl.rb +3 -2
- data/lib/nokogiri/xml/entity_reference.rb +1 -0
- data/lib/nokogiri/xml/namespace.rb +44 -0
- data/lib/nokogiri/xml/node/save_options.rb +14 -8
- data/lib/nokogiri/xml/node.rb +708 -383
- data/lib/nokogiri/xml/node_set.rb +134 -59
- data/lib/nokogiri/xml/notation.rb +12 -0
- data/lib/nokogiri/xml/parse_options.rb +140 -56
- data/lib/nokogiri/xml/pp/character_data.rb +8 -6
- data/lib/nokogiri/xml/pp/node.rb +26 -26
- data/lib/nokogiri/xml/pp.rb +1 -0
- data/lib/nokogiri/xml/processing_instruction.rb +3 -1
- data/lib/nokogiri/xml/reader.rb +20 -24
- data/lib/nokogiri/xml/relax_ng.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +20 -19
- data/lib/nokogiri/xml/sax/parser.rb +38 -36
- data/lib/nokogiri/xml/sax/parser_context.rb +7 -3
- data/lib/nokogiri/xml/sax/push_parser.rb +5 -5
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/schema.rb +7 -6
- data/lib/nokogiri/xml/searchable.rb +93 -62
- data/lib/nokogiri/xml/syntax_error.rb +5 -4
- data/lib/nokogiri/xml/text.rb +1 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
- data/lib/nokogiri/xml/xpath.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +2 -3
- data/lib/nokogiri/xml.rb +4 -3
- data/lib/nokogiri/xslt/stylesheet.rb +1 -0
- data/lib/nokogiri/xslt.rb +21 -13
- data/lib/nokogiri.rb +22 -27
- data/lib/xsd/xmlparser/nokogiri.rb +28 -25
- data/patches/libxml2/0009-allow-wildcard-namespaces.patch +77 -0
- data/patches/libxslt/0001-update-automake-files-for-arm64.patch +2445 -1919
- data/ports/archives/libxml2-2.10.4.tar.xz +0 -0
- data/ports/archives/libxslt-1.1.37.tar.xz +0 -0
- metadata +20 -171
- 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 -2511
- data/patches/libxml2/0007-Fix-XPath-recursion-limit.patch +0 -31
- data/patches/libxslt/0002-Fix-xml2-config-check-in-configure-script.patch +0 -19
- data/ports/archives/libxml2-2.9.12.tar.gz +0 -0
- data/ports/archives/libxslt-1.1.34.tar.gz +0 -0
@@ -31,7 +31,7 @@ get_type(VALUE self)
|
|
31
31
|
xmlElementContentPtr elem;
|
32
32
|
Data_Get_Struct(self, xmlElementContent, elem);
|
33
33
|
|
34
|
-
return INT2NUM(
|
34
|
+
return INT2NUM(elem->type);
|
35
35
|
}
|
36
36
|
|
37
37
|
/*
|
@@ -79,7 +79,7 @@ get_occur(VALUE self)
|
|
79
79
|
xmlElementContentPtr elem;
|
80
80
|
Data_Get_Struct(self, xmlElementContent, elem);
|
81
81
|
|
82
|
-
return INT2NUM(
|
82
|
+
return INT2NUM(elem->ocur);
|
83
83
|
}
|
84
84
|
|
85
85
|
/*
|
@@ -112,7 +112,7 @@ noko_xml_element_content_wrap(VALUE doc, xmlElementContentPtr element)
|
|
112
112
|
}
|
113
113
|
|
114
114
|
void
|
115
|
-
noko_init_xml_element_content()
|
115
|
+
noko_init_xml_element_content(void)
|
116
116
|
{
|
117
117
|
cNokogiriXmlElementContent = rb_define_class_under(mNokogiriXml, "ElementContent", rb_cObject);
|
118
118
|
|
@@ -14,8 +14,8 @@ static VALUE
|
|
14
14
|
element_type(VALUE self)
|
15
15
|
{
|
16
16
|
xmlElementPtr node;
|
17
|
-
|
18
|
-
return INT2NUM(
|
17
|
+
Noko_Node_Get_Struct(self, xmlElement, node);
|
18
|
+
return INT2NUM(node->etype);
|
19
19
|
}
|
20
20
|
|
21
21
|
/*
|
@@ -28,7 +28,7 @@ static VALUE
|
|
28
28
|
content(VALUE self)
|
29
29
|
{
|
30
30
|
xmlElementPtr node;
|
31
|
-
|
31
|
+
Noko_Node_Get_Struct(self, xmlElement, node);
|
32
32
|
|
33
33
|
if (!node->content) { return Qnil; }
|
34
34
|
|
@@ -48,7 +48,7 @@ static VALUE
|
|
48
48
|
prefix(VALUE self)
|
49
49
|
{
|
50
50
|
xmlElementPtr node;
|
51
|
-
|
51
|
+
Noko_Node_Get_Struct(self, xmlElement, node);
|
52
52
|
|
53
53
|
if (!node->prefix) { return Qnil; }
|
54
54
|
|
@@ -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);
|
@@ -3,70 +3,82 @@
|
|
3
3
|
VALUE cNokogiriEncodingHandler;
|
4
4
|
|
5
5
|
|
6
|
+
static void
|
7
|
+
_xml_encoding_handler_dealloc(xmlCharEncodingHandlerPtr c_handler)
|
8
|
+
{
|
9
|
+
/* make sure iconv handlers are cleaned up and freed */
|
10
|
+
xmlCharEncCloseFunc(c_handler);
|
11
|
+
}
|
12
|
+
|
13
|
+
|
6
14
|
/*
|
7
15
|
* call-seq: Nokogiri::EncodingHandler.[](name)
|
8
16
|
*
|
9
17
|
* Get the encoding handler for +name+
|
10
18
|
*/
|
11
19
|
static VALUE
|
12
|
-
|
20
|
+
rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
|
13
21
|
{
|
14
22
|
xmlCharEncodingHandlerPtr handler;
|
15
23
|
|
16
24
|
handler = xmlFindCharEncodingHandler(StringValueCStr(key));
|
17
25
|
if (handler) {
|
18
|
-
return Data_Wrap_Struct(klass, NULL,
|
26
|
+
return Data_Wrap_Struct(klass, NULL, _xml_encoding_handler_dealloc, handler);
|
19
27
|
}
|
20
28
|
|
21
29
|
return Qnil;
|
22
30
|
}
|
23
31
|
|
32
|
+
|
24
33
|
/*
|
25
34
|
* call-seq: Nokogiri::EncodingHandler.delete(name)
|
26
35
|
*
|
27
36
|
* Delete the encoding alias named +name+
|
28
37
|
*/
|
29
38
|
static VALUE
|
30
|
-
|
39
|
+
rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
|
31
40
|
{
|
32
41
|
if (xmlDelEncodingAlias(StringValueCStr(name))) { return Qnil; }
|
33
42
|
|
34
43
|
return Qtrue;
|
35
44
|
}
|
36
45
|
|
46
|
+
|
37
47
|
/*
|
38
|
-
* call-seq: Nokogiri::EncodingHandler.alias(
|
48
|
+
* call-seq: Nokogiri::EncodingHandler.alias(real_name, alias_name)
|
39
49
|
*
|
40
|
-
* Alias encoding handler with name +
|
50
|
+
* Alias encoding handler with name +real_name+ to name +alias_name+
|
41
51
|
*/
|
42
52
|
static VALUE
|
43
|
-
|
53
|
+
rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
|
44
54
|
{
|
45
55
|
xmlAddEncodingAlias(StringValueCStr(from), StringValueCStr(to));
|
46
56
|
|
47
57
|
return to;
|
48
58
|
}
|
49
59
|
|
60
|
+
|
50
61
|
/*
|
51
62
|
* call-seq: Nokogiri::EncodingHandler.clear_aliases!
|
52
63
|
*
|
53
64
|
* Remove all encoding aliases.
|
54
65
|
*/
|
55
66
|
static VALUE
|
56
|
-
|
67
|
+
rb_xml_encoding_handler_s_clear_aliases(VALUE klass)
|
57
68
|
{
|
58
69
|
xmlCleanupEncodingAliases();
|
59
70
|
|
60
71
|
return klass;
|
61
72
|
}
|
62
73
|
|
74
|
+
|
63
75
|
/*
|
64
76
|
* call-seq: name
|
65
77
|
*
|
66
78
|
* Get the name of this EncodingHandler
|
67
79
|
*/
|
68
80
|
static VALUE
|
69
|
-
|
81
|
+
rb_xml_encoding_handler_name(VALUE self)
|
70
82
|
{
|
71
83
|
xmlCharEncodingHandlerPtr handler;
|
72
84
|
|
@@ -75,16 +87,18 @@ name(VALUE self)
|
|
75
87
|
return NOKOGIRI_STR_NEW2(handler->name);
|
76
88
|
}
|
77
89
|
|
90
|
+
|
78
91
|
void
|
79
|
-
noko_init_xml_encoding_handler()
|
92
|
+
noko_init_xml_encoding_handler(void)
|
80
93
|
{
|
81
94
|
cNokogiriEncodingHandler = rb_define_class_under(mNokogiri, "EncodingHandler", rb_cObject);
|
82
95
|
|
83
96
|
rb_undef_alloc_func(cNokogiriEncodingHandler);
|
84
97
|
|
85
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "[]",
|
86
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "delete",
|
87
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "alias",
|
88
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!",
|
89
|
-
|
98
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "[]", rb_xml_encoding_handler_s_get, 1);
|
99
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "delete", rb_xml_encoding_handler_s_delete, 1);
|
100
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "alias", rb_xml_encoding_handler_s_alias, 2);
|
101
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!", rb_xml_encoding_handler_s_clear_aliases, 0);
|
102
|
+
|
103
|
+
rb_define_method(cNokogiriEncodingHandler, "name", rb_xml_encoding_handler_name, 0);
|
90
104
|
}
|
@@ -12,7 +12,7 @@ static VALUE
|
|
12
12
|
original_content(VALUE self)
|
13
13
|
{
|
14
14
|
xmlEntityPtr node;
|
15
|
-
|
15
|
+
Noko_Node_Get_Struct(self, xmlEntity, node);
|
16
16
|
|
17
17
|
if (!node->orig) { return Qnil; }
|
18
18
|
|
@@ -29,7 +29,7 @@ static VALUE
|
|
29
29
|
get_content(VALUE self)
|
30
30
|
{
|
31
31
|
xmlEntityPtr node;
|
32
|
-
|
32
|
+
Noko_Node_Get_Struct(self, xmlEntity, node);
|
33
33
|
|
34
34
|
if (!node->content) { return Qnil; }
|
35
35
|
|
@@ -46,7 +46,7 @@ static VALUE
|
|
46
46
|
entity_type(VALUE self)
|
47
47
|
{
|
48
48
|
xmlEntityPtr node;
|
49
|
-
|
49
|
+
Noko_Node_Get_Struct(self, xmlEntity, node);
|
50
50
|
|
51
51
|
return INT2NUM((int)node->etype);
|
52
52
|
}
|
@@ -61,7 +61,7 @@ static VALUE
|
|
61
61
|
external_id(VALUE self)
|
62
62
|
{
|
63
63
|
xmlEntityPtr node;
|
64
|
-
|
64
|
+
Noko_Node_Get_Struct(self, xmlEntity, node);
|
65
65
|
|
66
66
|
if (!node->ExternalID) { return Qnil; }
|
67
67
|
|
@@ -78,7 +78,7 @@ static VALUE
|
|
78
78
|
system_id(VALUE self)
|
79
79
|
{
|
80
80
|
xmlEntityPtr node;
|
81
|
-
|
81
|
+
Noko_Node_Get_Struct(self, xmlEntity, node);
|
82
82
|
|
83
83
|
if (!node->SystemID) { return Qnil; }
|
84
84
|
|
@@ -86,7 +86,7 @@ system_id(VALUE self)
|
|
86
86
|
}
|
87
87
|
|
88
88
|
void
|
89
|
-
noko_init_xml_entity_decl()
|
89
|
+
noko_init_xml_entity_decl(void)
|
90
90
|
{
|
91
91
|
assert(cNokogiriXmlNode);
|
92
92
|
cNokogiriXmlEntityDecl = rb_define_class_under(mNokogiriXml, "EntityDecl", cNokogiriXmlNode);
|
@@ -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,100 @@ 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
|
+
"Nokogiri/XMLNamespace/WithDealloc",
|
60
|
+
{0, _xml_namespace_dealloc, 0, _xml_namespace_update_references},
|
61
|
+
0, 0,
|
62
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
63
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
64
|
+
#endif
|
65
|
+
};
|
66
|
+
|
67
|
+
static const rb_data_type_t nokogiri_xml_namespace_type_without_dealloc = {
|
68
|
+
"Nokogiri/XMLNamespace/WithoutDealloc",
|
69
|
+
{0, 0, 0, _xml_namespace_update_references},
|
70
|
+
0, 0,
|
71
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
72
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
73
|
+
#endif
|
74
|
+
};
|
45
75
|
|
46
76
|
/*
|
47
|
-
*
|
48
|
-
*
|
77
|
+
* :call-seq:
|
78
|
+
* prefix() → String or nil
|
79
|
+
*
|
80
|
+
* Return the prefix for this Namespace, or +nil+ if there is no prefix (e.g., default namespace).
|
81
|
+
*
|
82
|
+
* *Example*
|
49
83
|
*
|
50
|
-
*
|
84
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
85
|
+
* <?xml version="1.0"?>
|
86
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
87
|
+
* <child1 foo="abc" noko:bar="def"/>
|
88
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
89
|
+
* </root>
|
90
|
+
* XML
|
91
|
+
*
|
92
|
+
* doc.root.elements.first.namespace.prefix
|
93
|
+
* # => nil
|
94
|
+
*
|
95
|
+
* doc.root.elements.last.namespace.prefix
|
96
|
+
* # => "noko"
|
51
97
|
*/
|
52
98
|
static VALUE
|
53
99
|
prefix(VALUE self)
|
54
100
|
{
|
55
101
|
xmlNsPtr ns;
|
56
102
|
|
57
|
-
|
103
|
+
Noko_Namespace_Get_Struct(self, xmlNs, ns);
|
58
104
|
if (!ns->prefix) { return Qnil; }
|
59
105
|
|
60
106
|
return NOKOGIRI_STR_NEW2(ns->prefix);
|
61
107
|
}
|
62
108
|
|
63
109
|
/*
|
64
|
-
*
|
65
|
-
*
|
110
|
+
* :call-seq:
|
111
|
+
* href() → String
|
112
|
+
*
|
113
|
+
* Returns the URI reference for this Namespace.
|
114
|
+
*
|
115
|
+
* *Example*
|
116
|
+
*
|
117
|
+
* doc = Nokogiri::XML.parse(<<~XML)
|
118
|
+
* <?xml version="1.0"?>
|
119
|
+
* <root xmlns="http://nokogiri.org/ns/default" xmlns:noko="http://nokogiri.org/ns/noko">
|
120
|
+
* <child1 foo="abc" noko:bar="def"/>
|
121
|
+
* <noko:child2 foo="qwe" noko:bar="rty"/>
|
122
|
+
* </root>
|
123
|
+
* XML
|
124
|
+
*
|
125
|
+
* doc.root.elements.first.namespace.href
|
126
|
+
* # => "http://nokogiri.org/ns/default"
|
66
127
|
*
|
67
|
-
*
|
128
|
+
* doc.root.elements.last.namespace.href
|
129
|
+
* # => "http://nokogiri.org/ns/noko"
|
68
130
|
*/
|
69
131
|
static VALUE
|
70
132
|
href(VALUE self)
|
71
133
|
{
|
72
134
|
xmlNsPtr ns;
|
73
135
|
|
74
|
-
|
136
|
+
Noko_Namespace_Get_Struct(self, xmlNs, ns);
|
75
137
|
if (!ns->href) { return Qnil; }
|
76
138
|
|
77
139
|
return NOKOGIRI_STR_NEW2(ns->href);
|
@@ -87,14 +149,18 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
|
|
87
149
|
}
|
88
150
|
|
89
151
|
if (c_document) {
|
90
|
-
rb_namespace =
|
152
|
+
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
153
|
+
&nokogiri_xml_namespace_type_without_dealloc,
|
154
|
+
c_namespace);
|
91
155
|
|
92
156
|
if (DOC_RUBY_OBJECT_TEST(c_document)) {
|
93
157
|
rb_iv_set(rb_namespace, "@document", DOC_RUBY_OBJECT(c_document));
|
94
158
|
rb_ary_push(DOC_NODE_CACHE(c_document), rb_namespace);
|
95
159
|
}
|
96
160
|
} else {
|
97
|
-
rb_namespace =
|
161
|
+
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
|
162
|
+
&nokogiri_xml_namespace_type_with_dealloc,
|
163
|
+
c_namespace);
|
98
164
|
}
|
99
165
|
|
100
166
|
c_namespace->_private = (void *)rb_namespace;
|
@@ -109,7 +175,7 @@ noko_xml_namespace_wrap_xpath_copy(xmlNsPtr c_namespace)
|
|
109
175
|
}
|
110
176
|
|
111
177
|
void
|
112
|
-
noko_init_xml_namespace()
|
178
|
+
noko_init_xml_namespace(void)
|
113
179
|
{
|
114
180
|
cNokogiriXmlNamespace = rb_define_class_under(mNokogiriXml, "Namespace", rb_cObject);
|
115
181
|
|