libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60
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.
- data/CHANGES +42 -0
- data/README +123 -117
- data/doc/classes/XML.html +226 -0
- data/doc/classes/XML/Attr.html +969 -0
- data/doc/classes/XML/Attributes.html +487 -0
- data/doc/classes/XML/Document.html +1423 -0
- data/doc/classes/XML/Dtd.html +159 -0
- data/doc/classes/XML/Error.html +111 -0
- data/doc/classes/XML/HTMLParser.html +330 -0
- data/doc/classes/XML/InputCallbacks.html +154 -0
- data/doc/classes/XML/NS.html +366 -0
- data/doc/classes/XML/Node.html +3292 -0
- data/doc/classes/XML/Node/FailedModify.html +111 -0
- data/doc/classes/XML/Node/Set.html +435 -0
- data/doc/classes/XML/Node/SetNamespace.html +111 -0
- data/doc/classes/XML/Node/UnknownType.html +111 -0
- data/doc/classes/XML/Parser.html +2178 -0
- data/doc/classes/XML/Parser/Context.html +1233 -0
- data/doc/classes/XML/Parser/ParseError.html +111 -0
- data/doc/classes/XML/Reader.html +2173 -0
- data/doc/classes/XML/SaxParser.html +396 -0
- data/doc/classes/XML/SiblingEnum.html +142 -0
- data/doc/classes/XML/State.html +118 -0
- data/doc/classes/XML/Tree.html +224 -0
- data/doc/classes/XML/XInclude.html +117 -0
- data/doc/classes/XML/XInclude/Error.html +111 -0
- data/doc/classes/XML/XMLParserOptions.html +198 -0
- data/doc/classes/XML/XPath.html +269 -0
- data/doc/classes/XML/XPath/Context.html +193 -0
- data/doc/classes/XML/XPath/InvalidPath.html +111 -0
- data/doc/classes/XML/XPath/Object.html +439 -0
- data/doc/classes/XML/XPointer.html +164 -0
- data/doc/classes/XML/XPointer/Context.html +117 -0
- data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
- data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
- data/doc/classes/singleton.html +114 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES.html +375 -0
- data/doc/files/LICENSE.html +133 -0
- data/doc/files/README.html +279 -0
- data/doc/files/VERSION.html +107 -0
- data/doc/files/ext/libxml/cbg_c.html +101 -0
- data/doc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
- data/doc/files/lib/libxml_rb.html +115 -0
- data/doc/files/lib/xml/libxml_rb.html +114 -0
- data/doc/fr_class_index.html +60 -0
- data/doc/fr_file_index.html +56 -0
- data/doc/fr_method_index.html +373 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/ext/libxml/cbg.c +76 -76
- data/ext/libxml/extconf.rb +308 -308
- data/ext/libxml/libxml.c +58 -62
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_attr.c +201 -113
- data/ext/libxml/ruby_xml_attr.h +6 -9
- data/ext/libxml/ruby_xml_attributes.c +268 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_document.c +80 -66
- data/ext/libxml/ruby_xml_dtd.c +2 -2
- data/ext/libxml/ruby_xml_dtd.h +17 -17
- data/ext/libxml/ruby_xml_html_parser.c +18 -19
- data/ext/libxml/ruby_xml_html_parser.h +29 -29
- data/ext/libxml/ruby_xml_input_cbg.c +6 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_node.c +438 -536
- data/ext/libxml/ruby_xml_node.h +17 -27
- data/ext/libxml/ruby_xml_node_set.c +10 -9
- data/ext/libxml/ruby_xml_node_set.h +20 -20
- data/ext/libxml/ruby_xml_ns.c +60 -69
- data/ext/libxml/ruby_xml_ns.h +12 -21
- data/ext/libxml/ruby_xml_parser.c +54 -53
- data/ext/libxml/ruby_xml_parser.h +31 -31
- data/ext/libxml/ruby_xml_parser_context.c +37 -91
- data/ext/libxml/ruby_xml_parser_context.h +20 -22
- data/ext/libxml/ruby_xml_reader.h +14 -14
- data/ext/libxml/ruby_xml_sax_parser.c +55 -55
- data/ext/libxml/ruby_xml_sax_parser.h +56 -56
- data/ext/libxml/ruby_xml_schema.c +44 -51
- data/ext/libxml/ruby_xml_schema.h +16 -16
- data/ext/libxml/ruby_xml_state.c +35 -96
- data/ext/libxml/ruby_xml_state.h +2 -3
- data/ext/libxml/ruby_xml_tree.h +12 -12
- data/ext/libxml/ruby_xml_xinclude.h +13 -13
- data/ext/libxml/ruby_xml_xpath.c +57 -18
- data/ext/libxml/ruby_xml_xpath.h +23 -23
- data/ext/libxml/ruby_xml_xpath_context.c +11 -7
- data/ext/libxml/ruby_xml_xpath_context.h +20 -20
- data/ext/libxml/ruby_xml_xpath_object.c +9 -16
- data/ext/libxml/ruby_xml_xpath_object.h +4 -10
- data/ext/libxml/ruby_xml_xpointer.c +11 -11
- data/ext/libxml/ruby_xml_xpointer.h +27 -27
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
- data/ext/libxml/version.h +2 -2
- data/lib/libxml.rb +134 -125
- data/lib/libxml_ruby.so +0 -0
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/test/ets_copy_bug.rb +1 -1
- data/test/ets_copy_bug2.rb +16 -27
- data/test/ets_doc_to_s.rb +1 -1
- data/test/ets_gpx.rb +1 -1
- data/test/ets_node_gc.rb +1 -1
- data/test/ets_tsr.rb +1 -1
- data/test/tc_well_formed.rb +1 -1
- data/test/tc_xml_attributes.rb +106 -0
- data/test/tc_xml_document.rb +10 -10
- data/test/tc_xml_document_write3.rb +1 -1
- data/test/tc_xml_dtd.rb +49 -0
- data/test/tc_xml_html_parser.rb +3 -3
- data/test/tc_xml_node.rb +69 -33
- data/test/tc_xml_node_attr.rb +170 -0
- data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
- data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
- data/test/tc_xml_node_edit.rb +91 -0
- data/test/tc_xml_parser.rb +97 -50
- data/test/tc_xml_parser_context.rb +61 -23
- data/test/tc_xml_schema.rb +39 -0
- data/test/tc_xml_xinclude.rb +5 -6
- data/test/tc_xml_xpath.rb +51 -27
- data/test/test_suite.rb +27 -0
- data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
- data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
- metadata +106 -54
- data/mingw/mingw.rake +0 -36
- data/test/dtd-test.rb +0 -24
- data/test/merge_bug.rb +0 -55
- data/test/schema-test.rb +0 -74
- data/test/tc_xml_node2.rb +0 -25
- data/test/tc_xml_node3.rb +0 -27
- data/test/tc_xml_node4.rb +0 -86
- data/test/tc_xml_node5.rb +0 -52
- data/test/tc_xml_node6.rb +0 -27
- data/test/tc_xml_node7.rb +0 -35
- data/test/tc_xml_parser2.rb +0 -16
- data/test/tc_xml_parser3.rb +0 -23
- data/test/tc_xml_parser4.rb +0 -33
- data/test/tc_xml_parser5.rb +0 -27
- data/test/tc_xml_parser6.rb +0 -23
- data/test/tc_xml_parser7.rb +0 -28
- data/test/tc_xml_parser8.rb +0 -32
- data/test/tc_xml_parser9.rb +0 -11
- data/test/tc_xml_xpath2.rb +0 -14
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
data/ext/libxml/libxml.c
CHANGED
@@ -1,62 +1,58 @@
|
|
1
|
-
/* $Id: libxml.c
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#include "ruby_libxml.h"
|
6
|
-
|
7
|
-
VALUE mXML;
|
8
|
-
VALUE eXMLError;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
|
61
|
-
ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
|
62
|
-
}
|
1
|
+
/* $Id: libxml.c 323 2008-07-08 22:59:23Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
|
7
|
+
VALUE mXML;
|
8
|
+
VALUE eXMLError;
|
9
|
+
|
10
|
+
|
11
|
+
#if defined(_WIN32)
|
12
|
+
__declspec(dllexport)
|
13
|
+
#endif
|
14
|
+
|
15
|
+
void
|
16
|
+
Init_libxml_ruby(void) {
|
17
|
+
/* Some libxml memory goo that should be done before anything else */
|
18
|
+
#ifdef NONE
|
19
|
+
xmlMemGet((xmlFreeFunc *) & freeFunc,
|
20
|
+
(xmlMallocFunc *) & mallocFunc,
|
21
|
+
(xmlReallocFunc *) & reallocFunc,
|
22
|
+
(xmlStrdupFunc *) & strdupFunc);
|
23
|
+
|
24
|
+
if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
|
25
|
+
(xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
|
26
|
+
rb_fatal("could not install the memory handlers for libxml");
|
27
|
+
#endif
|
28
|
+
|
29
|
+
mXML = rb_define_module("XML");
|
30
|
+
eXMLError = rb_define_class_under(mXML, "Error", rb_eRuntimeError);
|
31
|
+
|
32
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
|
33
|
+
|
34
|
+
ruby_init_state();
|
35
|
+
ruby_init_parser();
|
36
|
+
ruby_init_xml_parser_context();
|
37
|
+
ruby_init_xml_attributes();
|
38
|
+
ruby_init_xml_attr();
|
39
|
+
ruby_init_xml_document();
|
40
|
+
ruby_init_xml_node();
|
41
|
+
ruby_init_xml_node_set();
|
42
|
+
ruby_init_xml_ns();
|
43
|
+
ruby_init_xml_sax_parser();
|
44
|
+
ruby_init_xml_tree();
|
45
|
+
ruby_init_xml_xinclude();
|
46
|
+
ruby_init_xml_xpath();
|
47
|
+
ruby_init_xml_xpath_context();
|
48
|
+
ruby_init_xml_xpointer();
|
49
|
+
ruby_init_xml_xpointer_context();
|
50
|
+
ruby_init_html_parser();
|
51
|
+
ruby_init_input_callbacks();
|
52
|
+
ruby_init_xml_dtd();
|
53
|
+
ruby_init_xml_schema();
|
54
|
+
ruby_init_xml_reader();
|
55
|
+
|
56
|
+
ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
|
57
|
+
ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
|
58
|
+
}
|
data/ext/libxml/ruby_libxml.h
CHANGED
data/ext/libxml/ruby_xml_attr.c
CHANGED
@@ -1,103 +1,159 @@
|
|
1
|
-
/* $Id: ruby_xml_attr.c
|
1
|
+
/* $Id: ruby_xml_attr.c 351 2008-07-09 19:55:21Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
+
/*
|
6
|
+
* Document-class: XML::Attr
|
7
|
+
*
|
8
|
+
* Provides access to an single element attribute. Accessed by
|
9
|
+
* calling XML::Node#attributes method.
|
10
|
+
*
|
11
|
+
* Basic Usage:
|
12
|
+
* require 'libxml'
|
13
|
+
*
|
14
|
+
* doc = XML::Document.new(<some_file>)
|
15
|
+
* attribute = doc.root.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
16
|
+
* attribute.name == 'href'
|
17
|
+
* attribute.value == 'http://www.mydocument.com'
|
18
|
+
* attribute.remove!
|
19
|
+
*/
|
20
|
+
|
5
21
|
#include "ruby_libxml.h"
|
6
22
|
#include "ruby_xml_attr.h"
|
7
23
|
|
8
24
|
VALUE cXMLAttr;
|
9
25
|
|
10
|
-
void ruby_xml_attr_free(
|
11
|
-
if (
|
26
|
+
void ruby_xml_attr_free(xmlAttrPtr xattr) {
|
27
|
+
if (!xattr) return;
|
12
28
|
|
13
|
-
if (
|
14
|
-
|
15
|
-
if (
|
29
|
+
if (xattr != NULL ) {
|
30
|
+
xattr->_private=NULL;
|
31
|
+
if (xattr->parent == NULL && xattr->doc == NULL ) {
|
16
32
|
#ifdef NODE_DEBUG
|
17
33
|
fprintf(stderr,"ruby_xfree rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
|
18
34
|
#endif
|
19
|
-
xmlFreeProp(
|
35
|
+
xmlFreeProp(xattr);
|
20
36
|
}
|
21
37
|
|
22
|
-
|
38
|
+
xattr=NULL;
|
23
39
|
}
|
24
|
-
|
25
|
-
ruby_xfree(rx);
|
26
40
|
}
|
27
41
|
|
28
42
|
void
|
29
|
-
ruby_xml_attr_mark(
|
30
|
-
if (
|
31
|
-
if ( rx->attr == NULL ) return;
|
43
|
+
ruby_xml_attr_mark(xmlAttrPtr xattr) {
|
44
|
+
if (xattr == NULL) return;
|
32
45
|
|
33
|
-
if (
|
46
|
+
if (xattr->_private == NULL ) {
|
34
47
|
rb_warning("XmlAttr is not bound! (%s:%d)",
|
35
48
|
__FILE__,__LINE__);
|
36
49
|
return;
|
37
50
|
}
|
38
51
|
|
39
|
-
ruby_xml_node_mark_common((xmlNodePtr)
|
52
|
+
ruby_xml_node_mark_common((xmlNodePtr)xattr);
|
40
53
|
}
|
41
54
|
|
42
55
|
VALUE
|
43
|
-
ruby_xml_attr_wrap(
|
56
|
+
ruby_xml_attr_wrap(xmlAttrPtr xattr)
|
44
57
|
{
|
45
|
-
VALUE
|
46
|
-
ruby_xml_attr_t *rx;
|
47
|
-
|
58
|
+
VALUE result;
|
48
59
|
// This node is already wrapped
|
49
|
-
if (
|
50
|
-
return (VALUE)
|
60
|
+
if (xattr->_private != NULL)
|
61
|
+
return (VALUE)xattr->_private;
|
51
62
|
|
52
|
-
|
53
|
-
|
63
|
+
result = Data_Wrap_Struct(cXMLAttr,
|
64
|
+
ruby_xml_attr_mark, ruby_xml_attr_free,
|
65
|
+
xattr);
|
54
66
|
|
55
|
-
|
56
|
-
xnode->_private=(void*)obj;
|
67
|
+
xattr->_private=(void*)result;
|
57
68
|
#ifdef NODE_DEBUG
|
58
69
|
fprintf(stderr,"wrap rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)obj);
|
59
70
|
#endif
|
60
|
-
return
|
71
|
+
return result;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
VALUE
|
76
|
+
ruby_xml_attr_alloc(VALUE klass)
|
77
|
+
{
|
78
|
+
return Data_Wrap_Struct(cXMLAttr,
|
79
|
+
ruby_xml_attr_mark, ruby_xml_attr_free,
|
80
|
+
NULL);
|
61
81
|
}
|
62
82
|
|
63
83
|
/*
|
64
|
-
*
|
65
|
-
*
|
84
|
+
* call-seq:
|
85
|
+
* attr.initialize(node, "name", "value")
|
86
|
+
*
|
87
|
+
* Creates a new attribute for the node.
|
88
|
+
*
|
89
|
+
* node: The XML::Node that will contain the attribute
|
90
|
+
* name: The name of the attribute
|
91
|
+
* value: The value of the attribute
|
92
|
+
*
|
93
|
+
* attr = XML::Attr.new(doc.root, 'name', 'libxml')
|
66
94
|
*/
|
67
95
|
VALUE
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
96
|
+
ruby_xml_attr_initialize(int argc, VALUE *argv, VALUE self) {
|
97
|
+
VALUE node = argv[0];
|
98
|
+
VALUE name = argv[1];
|
99
|
+
VALUE value = argv[2];
|
100
|
+
VALUE ns = (argc == 4 ? argv[3] : Qnil);
|
101
|
+
|
102
|
+
xmlNodePtr xnode;
|
103
|
+
xmlAttrPtr xattr;
|
104
|
+
|
105
|
+
if ( argc < 3 || argc > 4 )
|
106
|
+
rb_raise(rb_eArgError, "wrong number of arguments (3 or 4)");
|
107
|
+
|
108
|
+
Check_Type(name, T_STRING);
|
109
|
+
Check_Type(value, T_STRING);
|
110
|
+
|
111
|
+
Data_Get_Struct(node, xmlNode, xnode);
|
112
|
+
|
113
|
+
if NIL_P(ns)
|
114
|
+
{
|
115
|
+
xattr = xmlNewProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
|
116
|
+
}
|
117
|
+
else
|
118
|
+
{
|
119
|
+
xmlNsPtr xns;
|
120
|
+
Data_Get_Struct(ns, xmlNs, xns);
|
121
|
+
xattr = xmlNewNsProp(xnode, xns, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value));
|
122
|
+
}
|
123
|
+
|
124
|
+
xattr->_private = (void *)self;
|
125
|
+
DATA_PTR(self) = xattr;
|
126
|
+
return self;
|
72
127
|
}
|
128
|
+
|
73
129
|
/*
|
74
130
|
* call-seq:
|
75
|
-
* attr.child
|
131
|
+
* attr.child -> node
|
76
132
|
*
|
77
133
|
* Obtain this attribute's child attribute(s).
|
78
134
|
*/
|
79
135
|
VALUE
|
80
136
|
ruby_xml_attr_child_get(VALUE self) {
|
81
|
-
|
82
|
-
Data_Get_Struct(self,
|
83
|
-
if (
|
137
|
+
xmlAttrPtr xattr;
|
138
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
139
|
+
if (xattr->children == NULL)
|
84
140
|
return(Qnil);
|
85
141
|
else
|
86
|
-
return(ruby_xml_node2_wrap(cXMLNode,
|
142
|
+
return(ruby_xml_node2_wrap(cXMLNode, (xmlNodePtr)xattr->children));
|
87
143
|
}
|
88
144
|
|
89
145
|
|
90
146
|
/*
|
91
147
|
* call-seq:
|
92
|
-
* attr.child?
|
148
|
+
* attr.child? -> (true|false)
|
93
149
|
*
|
94
150
|
* Determine whether this attribute has child attributes.
|
95
151
|
*/
|
96
152
|
VALUE
|
97
153
|
ruby_xml_attr_child_q(VALUE self) {
|
98
|
-
|
99
|
-
Data_Get_Struct(self,
|
100
|
-
if (
|
154
|
+
xmlAttrPtr xattr;
|
155
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
156
|
+
if (xattr->children == NULL)
|
101
157
|
return(Qfalse);
|
102
158
|
else
|
103
159
|
return(Qtrue);
|
@@ -106,33 +162,34 @@ ruby_xml_attr_child_q(VALUE self) {
|
|
106
162
|
|
107
163
|
/*
|
108
164
|
* call-seq:
|
109
|
-
* attr.doc
|
165
|
+
* attr.doc -> XML::Document
|
110
166
|
*
|
111
|
-
*
|
112
|
-
*
|
167
|
+
* Returns this attribute's document.
|
168
|
+
*
|
169
|
+
* doc.root.attributes.get_attribute('name').doc == doc
|
113
170
|
*/
|
114
171
|
VALUE
|
115
172
|
ruby_xml_attr_doc_get(VALUE self) {
|
116
|
-
|
117
|
-
Data_Get_Struct(self,
|
118
|
-
if (
|
173
|
+
xmlAttrPtr xattr;
|
174
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
175
|
+
if (xattr->doc == NULL)
|
119
176
|
return(Qnil);
|
120
177
|
else
|
121
|
-
return(ruby_xml_document_wrap(
|
178
|
+
return(ruby_xml_document_wrap(xattr->doc));
|
122
179
|
}
|
123
180
|
|
124
181
|
/*
|
125
182
|
* call-seq:
|
126
|
-
* attr.doc?
|
183
|
+
* attr.doc? -> (true|false)
|
127
184
|
*
|
128
185
|
* Determine whether this attribute is associated with an
|
129
186
|
* XML::Document.
|
130
187
|
*/
|
131
188
|
VALUE
|
132
189
|
ruby_xml_attr_doc_q(VALUE self) {
|
133
|
-
|
134
|
-
Data_Get_Struct(self,
|
135
|
-
if (
|
190
|
+
xmlAttrPtr xattr;
|
191
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
192
|
+
if (xattr->doc == NULL)
|
136
193
|
return(Qfalse);
|
137
194
|
else
|
138
195
|
return(Qtrue);
|
@@ -141,32 +198,32 @@ ruby_xml_attr_doc_q(VALUE self) {
|
|
141
198
|
|
142
199
|
/*
|
143
200
|
* call-seq:
|
144
|
-
* attr.last
|
201
|
+
* attr.last -> node
|
145
202
|
*
|
146
203
|
* Obtain the last attribute.
|
147
204
|
*/
|
148
205
|
VALUE
|
149
206
|
ruby_xml_attr_last_get(VALUE self) {
|
150
|
-
|
151
|
-
Data_Get_Struct(self,
|
152
|
-
if (
|
207
|
+
xmlAttrPtr xattr;
|
208
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
209
|
+
if (xattr->last == NULL)
|
153
210
|
return(Qnil);
|
154
211
|
else
|
155
|
-
return(ruby_xml_node2_wrap(cXMLNode,
|
212
|
+
return(ruby_xml_node2_wrap(cXMLNode, xattr->last));
|
156
213
|
}
|
157
214
|
|
158
215
|
|
159
216
|
/*
|
160
217
|
* call-seq:
|
161
|
-
* attr.last?
|
218
|
+
* attr.last? -> (true|false)
|
162
219
|
*
|
163
220
|
* Determine whether this is the last attribute.
|
164
221
|
*/
|
165
222
|
VALUE
|
166
223
|
ruby_xml_attr_last_q(VALUE self) {
|
167
|
-
|
168
|
-
Data_Get_Struct(self,
|
169
|
-
if (
|
224
|
+
xmlAttrPtr xattr;
|
225
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
226
|
+
if (xattr->last == NULL)
|
170
227
|
return(Qfalse);
|
171
228
|
else
|
172
229
|
return(Qtrue);
|
@@ -174,49 +231,49 @@ ruby_xml_attr_last_q(VALUE self) {
|
|
174
231
|
|
175
232
|
/*
|
176
233
|
* call-seq:
|
177
|
-
* attr.name
|
234
|
+
* attr.name -> "name"
|
178
235
|
*
|
179
236
|
* Obtain this attribute's name.
|
180
237
|
*/
|
181
238
|
VALUE
|
182
239
|
ruby_xml_attr_name_get(VALUE self) {
|
183
|
-
|
184
|
-
Data_Get_Struct(self,
|
240
|
+
xmlAttrPtr xattr;
|
241
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
185
242
|
|
186
|
-
if (
|
243
|
+
if (xattr->name == NULL)
|
187
244
|
return(Qnil);
|
188
245
|
else
|
189
|
-
return(rb_str_new2((const char*)
|
246
|
+
return(rb_str_new2((const char*)xattr->name));
|
190
247
|
}
|
191
248
|
|
192
249
|
/*
|
193
250
|
* call-seq:
|
194
|
-
* attr.next
|
251
|
+
* attr.next -> node
|
195
252
|
*
|
196
253
|
* Obtain the next attribute.
|
197
254
|
*/
|
198
255
|
VALUE
|
199
256
|
ruby_xml_attr_next_get(VALUE self) {
|
200
|
-
|
201
|
-
Data_Get_Struct(self,
|
202
|
-
if (
|
257
|
+
xmlAttrPtr xattr;
|
258
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
259
|
+
if (xattr->next == NULL)
|
203
260
|
return(Qnil);
|
204
261
|
else
|
205
|
-
return(ruby_xml_attr_wrap(
|
262
|
+
return(ruby_xml_attr_wrap(xattr->next));
|
206
263
|
}
|
207
264
|
|
208
265
|
|
209
266
|
/*
|
210
267
|
* call-seq:
|
211
|
-
* attr.next?
|
268
|
+
* attr.next? -> (true|false)
|
212
269
|
*
|
213
270
|
* Determine whether there is a next attribute.
|
214
271
|
*/
|
215
272
|
VALUE
|
216
273
|
ruby_xml_attr_next_q(VALUE self) {
|
217
|
-
|
218
|
-
Data_Get_Struct(self,
|
219
|
-
if (
|
274
|
+
xmlAttrPtr xattr;
|
275
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
276
|
+
if (xattr->next == NULL)
|
220
277
|
return(Qfalse);
|
221
278
|
else
|
222
279
|
return(Qtrue);
|
@@ -225,7 +282,7 @@ ruby_xml_attr_next_q(VALUE self) {
|
|
225
282
|
|
226
283
|
/*
|
227
284
|
* call-seq:
|
228
|
-
* attr.type_name
|
285
|
+
* attr.type_name -> "attribute"
|
229
286
|
*
|
230
287
|
* Obtain this attribute node's type name.
|
231
288
|
*/
|
@@ -237,33 +294,33 @@ ruby_xml_attr_node_type_name(VALUE self) {
|
|
237
294
|
|
238
295
|
/*
|
239
296
|
* call-seq:
|
240
|
-
* attr.ns
|
297
|
+
* attr.ns -> namespace
|
241
298
|
*
|
242
299
|
* Obtain this attribute's associated XML::NS, if any.
|
243
300
|
*/
|
244
301
|
VALUE
|
245
302
|
ruby_xml_attr_ns_get(VALUE self) {
|
246
|
-
|
247
|
-
Data_Get_Struct(self,
|
248
|
-
if (
|
303
|
+
xmlAttrPtr xattr;
|
304
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
305
|
+
if (xattr->ns == NULL)
|
249
306
|
return(Qnil);
|
250
307
|
else
|
251
|
-
return(
|
308
|
+
return(ruby_xml_ns_wrap(xattr->ns));
|
252
309
|
}
|
253
310
|
|
254
311
|
|
255
312
|
/*
|
256
313
|
* call-seq:
|
257
|
-
* attr.ns?
|
314
|
+
* attr.ns? -> (true|false)
|
258
315
|
*
|
259
316
|
* Determine whether this attribute has an associated
|
260
317
|
* namespace.
|
261
318
|
*/
|
262
319
|
VALUE
|
263
320
|
ruby_xml_attr_ns_q(VALUE self) {
|
264
|
-
|
265
|
-
Data_Get_Struct(self,
|
266
|
-
if (
|
321
|
+
xmlAttrPtr xattr;
|
322
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
323
|
+
if (xattr->ns == NULL)
|
267
324
|
return(Qfalse);
|
268
325
|
else
|
269
326
|
return(Qtrue);
|
@@ -272,32 +329,32 @@ ruby_xml_attr_ns_q(VALUE self) {
|
|
272
329
|
|
273
330
|
/*
|
274
331
|
* call-seq:
|
275
|
-
* attr.parent
|
332
|
+
* attr.parent -> node
|
276
333
|
*
|
277
334
|
* Obtain this attribute node's parent.
|
278
335
|
*/
|
279
336
|
VALUE
|
280
337
|
ruby_xml_attr_parent_get(VALUE self) {
|
281
|
-
|
282
|
-
Data_Get_Struct(self,
|
283
|
-
if (
|
338
|
+
xmlAttrPtr xattr;
|
339
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
340
|
+
if (xattr->parent == NULL)
|
284
341
|
return(Qnil);
|
285
342
|
else
|
286
|
-
return(ruby_xml_node2_wrap(cXMLNode,
|
343
|
+
return(ruby_xml_node2_wrap(cXMLNode, xattr->parent));
|
287
344
|
}
|
288
345
|
|
289
346
|
|
290
347
|
/*
|
291
348
|
* call-seq:
|
292
|
-
* attr.parent?
|
349
|
+
* attr.parent? -> (true|false)
|
293
350
|
*
|
294
351
|
* Determine whether this attribute has a parent.
|
295
352
|
*/
|
296
353
|
VALUE
|
297
354
|
ruby_xml_attr_parent_q(VALUE self) {
|
298
|
-
|
299
|
-
Data_Get_Struct(self,
|
300
|
-
if (
|
355
|
+
xmlAttrPtr xattr;
|
356
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
357
|
+
if (xattr->parent == NULL)
|
301
358
|
return(Qfalse);
|
302
359
|
else
|
303
360
|
return(Qtrue);
|
@@ -306,32 +363,32 @@ ruby_xml_attr_parent_q(VALUE self) {
|
|
306
363
|
|
307
364
|
/*
|
308
365
|
* call-seq:
|
309
|
-
* attr.prev
|
366
|
+
* attr.prev -> node
|
310
367
|
*
|
311
368
|
* Obtain the previous attribute.
|
312
369
|
*/
|
313
370
|
VALUE
|
314
371
|
ruby_xml_attr_prev_get(VALUE self) {
|
315
|
-
|
316
|
-
Data_Get_Struct(self,
|
317
|
-
if (
|
372
|
+
xmlAttrPtr xattr;
|
373
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
374
|
+
if (xattr->prev == NULL)
|
318
375
|
return(Qnil);
|
319
376
|
else
|
320
|
-
return(ruby_xml_attr_wrap(
|
377
|
+
return(ruby_xml_attr_wrap(xattr->prev));
|
321
378
|
}
|
322
379
|
|
323
380
|
|
324
381
|
/*
|
325
382
|
* call-seq:
|
326
|
-
* attr.prev?
|
383
|
+
* attr.prev? -> (true|false)
|
327
384
|
*
|
328
385
|
* Determine whether there is a previous attribute.
|
329
386
|
*/
|
330
387
|
VALUE
|
331
388
|
ruby_xml_attr_prev_q(VALUE self) {
|
332
|
-
|
333
|
-
Data_Get_Struct(self,
|
334
|
-
if (
|
389
|
+
xmlAttrPtr xattr;
|
390
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
391
|
+
if (xattr->prev == NULL)
|
335
392
|
return(Qfalse);
|
336
393
|
else
|
337
394
|
return(Qtrue);
|
@@ -340,33 +397,38 @@ ruby_xml_attr_prev_q(VALUE self) {
|
|
340
397
|
|
341
398
|
/*
|
342
399
|
* call-seq:
|
343
|
-
* node.remove!
|
400
|
+
* node.remove! -> nil
|
344
401
|
*
|
345
402
|
* Removes this attribute from it's parent.
|
346
403
|
*/
|
347
404
|
VALUE
|
348
405
|
ruby_xml_attr_remove_ex(VALUE self) {
|
349
|
-
|
350
|
-
Data_Get_Struct(self,
|
351
|
-
|
406
|
+
xmlAttrPtr xattr;
|
407
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
408
|
+
|
409
|
+
if (xattr->_private == NULL)
|
410
|
+
xmlRemoveProp(xattr);
|
411
|
+
else
|
412
|
+
xmlUnlinkNode((xmlNodePtr)xattr);
|
413
|
+
|
352
414
|
return(Qnil);
|
353
415
|
}
|
354
416
|
|
355
417
|
/*
|
356
418
|
* call-seq:
|
357
|
-
* attr.value
|
419
|
+
* attr.value -> "value"
|
358
420
|
*
|
359
421
|
* Obtain the value of this attribute.
|
360
422
|
*/
|
361
423
|
VALUE
|
362
|
-
|
363
|
-
|
424
|
+
ruby_xml_attr_value_get(VALUE self) {
|
425
|
+
xmlAttrPtr xattr;
|
364
426
|
xmlChar *value;
|
365
427
|
VALUE result = Qnil;
|
366
428
|
|
367
|
-
Data_Get_Struct(self,
|
429
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
368
430
|
if (ruby_xml_attr_parent_q(self) == Qtrue) {
|
369
|
-
value = xmlGetProp(
|
431
|
+
value = xmlGetProp(xattr->parent, xattr->name);
|
370
432
|
if (value != NULL)
|
371
433
|
{
|
372
434
|
result = rb_str_new2((const char*)value);
|
@@ -376,6 +438,29 @@ ruby_xml_attr_value(VALUE self) {
|
|
376
438
|
return(result);
|
377
439
|
}
|
378
440
|
|
441
|
+
|
442
|
+
/*
|
443
|
+
* call-seq:
|
444
|
+
* attr.value = "value"
|
445
|
+
*
|
446
|
+
* Sets the value of this attribute.
|
447
|
+
*/
|
448
|
+
VALUE
|
449
|
+
ruby_xml_attr_value_set(VALUE self, VALUE val) {
|
450
|
+
xmlAttrPtr xattr;
|
451
|
+
|
452
|
+
Check_Type(val, T_STRING);
|
453
|
+
Data_Get_Struct(self, xmlAttr, xattr);
|
454
|
+
|
455
|
+
if (xattr->ns)
|
456
|
+
xmlSetNsProp(xattr->parent, xattr->ns, xattr->name, (xmlChar*)StringValuePtr(val));
|
457
|
+
else
|
458
|
+
xmlSetProp(xattr->parent, xattr->name, (xmlChar*)StringValuePtr(val));
|
459
|
+
|
460
|
+
return(self);
|
461
|
+
}
|
462
|
+
|
463
|
+
|
379
464
|
// Rdoc needs to know
|
380
465
|
#ifdef RDOC_NEVER_DEFINED
|
381
466
|
mXML = rb_define_module("XML");
|
@@ -384,6 +469,8 @@ ruby_xml_attr_value(VALUE self) {
|
|
384
469
|
void
|
385
470
|
ruby_init_xml_attr(void) {
|
386
471
|
cXMLAttr = rb_define_class_under(mXML, "Attr", rb_cObject);
|
472
|
+
rb_define_alloc_func(cXMLAttr, ruby_xml_attr_alloc);
|
473
|
+
rb_define_method(cXMLAttr, "initialize", ruby_xml_attr_initialize, -1);
|
387
474
|
rb_define_method(cXMLAttr, "child", ruby_xml_attr_child_get, 0);
|
388
475
|
rb_define_method(cXMLAttr, "child?", ruby_xml_attr_child_q, 0);
|
389
476
|
rb_define_method(cXMLAttr, "doc", ruby_xml_attr_doc_get, 0);
|
@@ -401,5 +488,6 @@ ruby_init_xml_attr(void) {
|
|
401
488
|
rb_define_method(cXMLAttr, "prev", ruby_xml_attr_prev_get, 0);
|
402
489
|
rb_define_method(cXMLAttr, "prev?", ruby_xml_attr_prev_q, 0);
|
403
490
|
rb_define_method(cXMLAttr, "remove!", ruby_xml_attr_remove_ex, 0);
|
404
|
-
rb_define_method(cXMLAttr, "value",
|
491
|
+
rb_define_method(cXMLAttr, "value", ruby_xml_attr_value_get, 0);
|
492
|
+
rb_define_method(cXMLAttr, "value=", ruby_xml_attr_value_set, 1);
|
405
493
|
}
|