libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/CHANGES +42 -0
  2. data/README +123 -117
  3. data/doc/classes/XML.html +226 -0
  4. data/doc/classes/XML/Attr.html +969 -0
  5. data/doc/classes/XML/Attributes.html +487 -0
  6. data/doc/classes/XML/Document.html +1423 -0
  7. data/doc/classes/XML/Dtd.html +159 -0
  8. data/doc/classes/XML/Error.html +111 -0
  9. data/doc/classes/XML/HTMLParser.html +330 -0
  10. data/doc/classes/XML/InputCallbacks.html +154 -0
  11. data/doc/classes/XML/NS.html +366 -0
  12. data/doc/classes/XML/Node.html +3292 -0
  13. data/doc/classes/XML/Node/FailedModify.html +111 -0
  14. data/doc/classes/XML/Node/Set.html +435 -0
  15. data/doc/classes/XML/Node/SetNamespace.html +111 -0
  16. data/doc/classes/XML/Node/UnknownType.html +111 -0
  17. data/doc/classes/XML/Parser.html +2178 -0
  18. data/doc/classes/XML/Parser/Context.html +1233 -0
  19. data/doc/classes/XML/Parser/ParseError.html +111 -0
  20. data/doc/classes/XML/Reader.html +2173 -0
  21. data/doc/classes/XML/SaxParser.html +396 -0
  22. data/doc/classes/XML/SiblingEnum.html +142 -0
  23. data/doc/classes/XML/State.html +118 -0
  24. data/doc/classes/XML/Tree.html +224 -0
  25. data/doc/classes/XML/XInclude.html +117 -0
  26. data/doc/classes/XML/XInclude/Error.html +111 -0
  27. data/doc/classes/XML/XMLParserOptions.html +198 -0
  28. data/doc/classes/XML/XPath.html +269 -0
  29. data/doc/classes/XML/XPath/Context.html +193 -0
  30. data/doc/classes/XML/XPath/InvalidPath.html +111 -0
  31. data/doc/classes/XML/XPath/Object.html +439 -0
  32. data/doc/classes/XML/XPointer.html +164 -0
  33. data/doc/classes/XML/XPointer/Context.html +117 -0
  34. data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
  35. data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
  36. data/doc/classes/singleton.html +114 -0
  37. data/doc/created.rid +1 -0
  38. data/doc/files/CHANGES.html +375 -0
  39. data/doc/files/LICENSE.html +133 -0
  40. data/doc/files/README.html +279 -0
  41. data/doc/files/VERSION.html +107 -0
  42. data/doc/files/ext/libxml/cbg_c.html +101 -0
  43. data/doc/files/ext/libxml/libxml_c.html +101 -0
  44. data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
  45. data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
  46. data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
  47. data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
  48. data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
  49. data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
  50. data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
  51. data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
  52. data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
  53. data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
  54. data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
  55. data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
  56. data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
  57. data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
  58. data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
  59. data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
  60. data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
  61. data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
  62. data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
  63. data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
  64. data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
  65. data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
  66. data/doc/files/lib/libxml_rb.html +115 -0
  67. data/doc/files/lib/xml/libxml_rb.html +114 -0
  68. data/doc/fr_class_index.html +60 -0
  69. data/doc/fr_file_index.html +56 -0
  70. data/doc/fr_method_index.html +373 -0
  71. data/doc/index.html +24 -0
  72. data/doc/rdoc-style.css +208 -0
  73. data/ext/libxml/cbg.c +76 -76
  74. data/ext/libxml/extconf.rb +308 -308
  75. data/ext/libxml/libxml.c +58 -62
  76. data/ext/libxml/ruby_libxml.h +1 -0
  77. data/ext/libxml/ruby_xml_attr.c +201 -113
  78. data/ext/libxml/ruby_xml_attr.h +6 -9
  79. data/ext/libxml/ruby_xml_attributes.c +268 -0
  80. data/ext/libxml/ruby_xml_attributes.h +17 -0
  81. data/ext/libxml/ruby_xml_document.c +80 -66
  82. data/ext/libxml/ruby_xml_dtd.c +2 -2
  83. data/ext/libxml/ruby_xml_dtd.h +17 -17
  84. data/ext/libxml/ruby_xml_html_parser.c +18 -19
  85. data/ext/libxml/ruby_xml_html_parser.h +29 -29
  86. data/ext/libxml/ruby_xml_input_cbg.c +6 -0
  87. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  88. data/ext/libxml/ruby_xml_node.c +438 -536
  89. data/ext/libxml/ruby_xml_node.h +17 -27
  90. data/ext/libxml/ruby_xml_node_set.c +10 -9
  91. data/ext/libxml/ruby_xml_node_set.h +20 -20
  92. data/ext/libxml/ruby_xml_ns.c +60 -69
  93. data/ext/libxml/ruby_xml_ns.h +12 -21
  94. data/ext/libxml/ruby_xml_parser.c +54 -53
  95. data/ext/libxml/ruby_xml_parser.h +31 -31
  96. data/ext/libxml/ruby_xml_parser_context.c +37 -91
  97. data/ext/libxml/ruby_xml_parser_context.h +20 -22
  98. data/ext/libxml/ruby_xml_reader.h +14 -14
  99. data/ext/libxml/ruby_xml_sax_parser.c +55 -55
  100. data/ext/libxml/ruby_xml_sax_parser.h +56 -56
  101. data/ext/libxml/ruby_xml_schema.c +44 -51
  102. data/ext/libxml/ruby_xml_schema.h +16 -16
  103. data/ext/libxml/ruby_xml_state.c +35 -96
  104. data/ext/libxml/ruby_xml_state.h +2 -3
  105. data/ext/libxml/ruby_xml_tree.h +12 -12
  106. data/ext/libxml/ruby_xml_xinclude.h +13 -13
  107. data/ext/libxml/ruby_xml_xpath.c +57 -18
  108. data/ext/libxml/ruby_xml_xpath.h +23 -23
  109. data/ext/libxml/ruby_xml_xpath_context.c +11 -7
  110. data/ext/libxml/ruby_xml_xpath_context.h +20 -20
  111. data/ext/libxml/ruby_xml_xpath_object.c +9 -16
  112. data/ext/libxml/ruby_xml_xpath_object.h +4 -10
  113. data/ext/libxml/ruby_xml_xpointer.c +11 -11
  114. data/ext/libxml/ruby_xml_xpointer.h +27 -27
  115. data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
  116. data/ext/libxml/version.h +2 -2
  117. data/lib/libxml.rb +134 -125
  118. data/lib/libxml_ruby.so +0 -0
  119. data/mingw/libiconv-2.dll +0 -0
  120. data/mingw/libxml2-2.dll +0 -0
  121. data/mingw/libxml_ruby.so +0 -0
  122. data/test/ets_copy_bug.rb +1 -1
  123. data/test/ets_copy_bug2.rb +16 -27
  124. data/test/ets_doc_to_s.rb +1 -1
  125. data/test/ets_gpx.rb +1 -1
  126. data/test/ets_node_gc.rb +1 -1
  127. data/test/ets_tsr.rb +1 -1
  128. data/test/tc_well_formed.rb +1 -1
  129. data/test/tc_xml_attributes.rb +106 -0
  130. data/test/tc_xml_document.rb +10 -10
  131. data/test/tc_xml_document_write3.rb +1 -1
  132. data/test/tc_xml_dtd.rb +49 -0
  133. data/test/tc_xml_html_parser.rb +3 -3
  134. data/test/tc_xml_node.rb +69 -33
  135. data/test/tc_xml_node_attr.rb +170 -0
  136. data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
  137. data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
  138. data/test/tc_xml_node_edit.rb +91 -0
  139. data/test/tc_xml_parser.rb +97 -50
  140. data/test/tc_xml_parser_context.rb +61 -23
  141. data/test/tc_xml_schema.rb +39 -0
  142. data/test/tc_xml_xinclude.rb +5 -6
  143. data/test/tc_xml_xpath.rb +51 -27
  144. data/test/test_suite.rb +27 -0
  145. data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
  146. data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
  147. metadata +106 -54
  148. data/mingw/mingw.rake +0 -36
  149. data/test/dtd-test.rb +0 -24
  150. data/test/merge_bug.rb +0 -55
  151. data/test/schema-test.rb +0 -74
  152. data/test/tc_xml_node2.rb +0 -25
  153. data/test/tc_xml_node3.rb +0 -27
  154. data/test/tc_xml_node4.rb +0 -86
  155. data/test/tc_xml_node5.rb +0 -52
  156. data/test/tc_xml_node6.rb +0 -27
  157. data/test/tc_xml_node7.rb +0 -35
  158. data/test/tc_xml_parser2.rb +0 -16
  159. data/test/tc_xml_parser3.rb +0 -23
  160. data/test/tc_xml_parser4.rb +0 -33
  161. data/test/tc_xml_parser5.rb +0 -27
  162. data/test/tc_xml_parser6.rb +0 -23
  163. data/test/tc_xml_parser7.rb +0 -28
  164. data/test/tc_xml_parser8.rb +0 -32
  165. data/test/tc_xml_parser9.rb +0 -11
  166. data/test/tc_xml_xpath2.rb +0 -14
  167. data/work/vc/debug/libxml.exp +0 -0
  168. data/work/vc/debug/libxml.ilk +0 -0
  169. data/work/vc/debug/libxml.lib +0 -0
  170. data/work/vc/debug/libxml.pdb +0 -0
  171. data/work/vc/debug/libxml.so +0 -0
data/ext/libxml/libxml.c CHANGED
@@ -1,62 +1,58 @@
1
- /* $Id: libxml.c 300 2008-07-01 19:14:15Z 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
- static xmlFreeFunc freeFunc = NULL;
11
- static xmlMallocFunc mallocFunc = NULL;
12
- static xmlReallocFunc reallocFunc = NULL;
13
- static xmlStrdupFunc strdupFunc = NULL;
14
-
15
- #if defined(_WIN32)
16
- __declspec(dllexport)
17
- #endif
18
-
19
- void
20
- Init_libxml_ruby(void) {
21
- /* Some libxml memory goo that should be done before anything else */
22
- #ifdef NONE
23
- xmlMemGet((xmlFreeFunc *) & freeFunc,
24
- (xmlMallocFunc *) & mallocFunc,
25
- (xmlReallocFunc *) & reallocFunc,
26
- (xmlStrdupFunc *) & strdupFunc);
27
-
28
- if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
29
- (xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
30
- rb_fatal("could not install the memory handlers for libxml");
31
- #endif
32
- xmlInitParser();
33
-
34
- mXML = rb_define_module("XML");
35
- eXMLError = rb_define_class_under(mXML, "Error", rb_eRuntimeError);
36
-
37
- rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
38
-
39
- ruby_init_state();
40
- ruby_init_parser();
41
- ruby_init_xml_parser_context();
42
- ruby_init_xml_attr();
43
- ruby_init_xml_document();
44
- ruby_init_xml_node();
45
- ruby_init_xml_node_set();
46
- ruby_init_xml_ns();
47
- ruby_init_xml_sax_parser();
48
- ruby_init_xml_tree();
49
- ruby_init_xml_xinclude();
50
- ruby_init_xml_xpath();
51
- ruby_init_xml_xpath_context();
52
- ruby_init_xml_xpointer();
53
- ruby_init_xml_xpointer_context();
54
- ruby_init_html_parser();
55
- ruby_init_input_callbacks();
56
- ruby_init_xml_dtd();
57
- ruby_init_xml_schema();
58
- ruby_init_xml_reader();
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
+ }
@@ -63,6 +63,7 @@ typedef struct rx_xpath_data {
63
63
  } rx_xpath_data;
64
64
 
65
65
  #include "ruby_xml_state.h"
66
+ #include "ruby_xml_attributes.h"
66
67
  #include "ruby_xml_attr.h"
67
68
  #include "ruby_xml_document.h"
68
69
  #include "ruby_xml_node.h"
@@ -1,103 +1,159 @@
1
- /* $Id: ruby_xml_attr.c 300 2008-07-01 19:14:15Z cfis $ */
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(ruby_xml_attr_t *rx) {
11
- if (rx == NULL ) return;
26
+ void ruby_xml_attr_free(xmlAttrPtr xattr) {
27
+ if (!xattr) return;
12
28
 
13
- if (rx->attr != NULL ) {
14
- rx->attr->_private=NULL;
15
- if (rx->attr->parent == NULL && rx->attr->doc == NULL ) {
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(rx->attr);
35
+ xmlFreeProp(xattr);
20
36
  }
21
37
 
22
- rx->attr=NULL;
38
+ xattr=NULL;
23
39
  }
24
-
25
- ruby_xfree(rx);
26
40
  }
27
41
 
28
42
  void
29
- ruby_xml_attr_mark(ruby_xml_attr_t *rx) {
30
- if ( rx == NULL ) return;
31
- if ( rx->attr == NULL ) return;
43
+ ruby_xml_attr_mark(xmlAttrPtr xattr) {
44
+ if (xattr == NULL) return;
32
45
 
33
- if (rx->attr->_private == NULL ) {
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)rx->attr);
52
+ ruby_xml_node_mark_common((xmlNodePtr)xattr);
40
53
  }
41
54
 
42
55
  VALUE
43
- ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode)
56
+ ruby_xml_attr_wrap(xmlAttrPtr xattr)
44
57
  {
45
- VALUE obj;
46
- ruby_xml_attr_t *rx;
47
-
58
+ VALUE result;
48
59
  // This node is already wrapped
49
- if (xnode->_private != NULL)
50
- return (VALUE)xnode->_private;
60
+ if (xattr->_private != NULL)
61
+ return (VALUE)xattr->_private;
51
62
 
52
- obj=Data_Make_Struct(class,ruby_xml_attr_t,ruby_xml_attr_mark,
53
- ruby_xml_attr_free,rx);
63
+ result = Data_Wrap_Struct(cXMLAttr,
64
+ ruby_xml_attr_mark, ruby_xml_attr_free,
65
+ xattr);
54
66
 
55
- rx->attr=xnode;
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 obj;
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
- * Only use this when a xmlAttr has just been created since
65
- * oblitterates the _private. Not exposed to ruby interp.
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
- ruby_xml_attr_new(VALUE class, xmlAttrPtr xnode)
69
- {
70
- xnode->_private=NULL;
71
- return ruby_xml_attr_wrap(class,xnode);
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 => node
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
- ruby_xml_attr_t *rxa;
82
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
83
- if (rxa->attr->children == NULL)
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, rxa->attr->children));
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? => (true|false)
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
- ruby_xml_attr_t *rxa;
99
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
100
- if (rxa->attr->children == NULL)
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 => document
165
+ * attr.doc -> XML::Document
110
166
  *
111
- * Obtain the XML::Document this attribute is associated with,
112
- * if any.
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
- ruby_xml_attr_t *rxa;
117
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
118
- if (rxa->attr->doc == NULL)
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(rxa->attr->doc));
178
+ return(ruby_xml_document_wrap(xattr->doc));
122
179
  }
123
180
 
124
181
  /*
125
182
  * call-seq:
126
- * attr.doc? => (true|false)
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
- ruby_xml_attr_t *rxa;
134
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
135
- if (rxa->attr->doc == NULL)
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 => node
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
- ruby_xml_attr_t *rxa;
151
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
152
- if (rxa->attr->last == NULL)
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, rxa->attr->last));
212
+ return(ruby_xml_node2_wrap(cXMLNode, xattr->last));
156
213
  }
157
214
 
158
215
 
159
216
  /*
160
217
  * call-seq:
161
- * attr.last? => (true|false)
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
- ruby_xml_attr_t *rxa;
168
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
169
- if (rxa->attr->last == NULL)
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 => "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
- ruby_xml_attr_t *rxa;
184
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
240
+ xmlAttrPtr xattr;
241
+ Data_Get_Struct(self, xmlAttr, xattr);
185
242
 
186
- if (rxa->attr->name == NULL)
243
+ if (xattr->name == NULL)
187
244
  return(Qnil);
188
245
  else
189
- return(rb_str_new2((const char*)rxa->attr->name));
246
+ return(rb_str_new2((const char*)xattr->name));
190
247
  }
191
248
 
192
249
  /*
193
250
  * call-seq:
194
- * attr.next => node
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
- ruby_xml_attr_t *rxa;
201
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
202
- if (rxa->attr->next == NULL)
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(cXMLAttr, rxa->attr->next));
262
+ return(ruby_xml_attr_wrap(xattr->next));
206
263
  }
207
264
 
208
265
 
209
266
  /*
210
267
  * call-seq:
211
- * attr.next? => (true|false)
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
- ruby_xml_attr_t *rxa;
218
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
219
- if (rxa->attr->next == NULL)
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 => "attribute"
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 => namespace
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
- ruby_xml_attr_t *rxa;
247
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
248
- if (rxa->attr->ns == NULL)
303
+ xmlAttrPtr xattr;
304
+ Data_Get_Struct(self, xmlAttr, xattr);
305
+ if (xattr->ns == NULL)
249
306
  return(Qnil);
250
307
  else
251
- return(ruby_xml_ns_new2(cXMLNS, Qnil, rxa->attr->ns));
308
+ return(ruby_xml_ns_wrap(xattr->ns));
252
309
  }
253
310
 
254
311
 
255
312
  /*
256
313
  * call-seq:
257
- * attr.ns? => (true|false)
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
- ruby_xml_attr_t *rxa;
265
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
266
- if (rxa->attr->ns == NULL)
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 => node
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
- ruby_xml_attr_t *rxa;
282
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
283
- if (rxa->attr->parent == NULL)
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, rxa->attr->parent));
343
+ return(ruby_xml_node2_wrap(cXMLNode, xattr->parent));
287
344
  }
288
345
 
289
346
 
290
347
  /*
291
348
  * call-seq:
292
- * attr.parent? => (true|false)
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
- ruby_xml_attr_t *rxa;
299
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
300
- if (rxa->attr->parent == NULL)
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 => node
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
- ruby_xml_attr_t *rxa;
316
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
317
- if (rxa->attr->prev == NULL)
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(cXMLAttr, rxa->attr->prev));
377
+ return(ruby_xml_attr_wrap(xattr->prev));
321
378
  }
322
379
 
323
380
 
324
381
  /*
325
382
  * call-seq:
326
- * attr.prev? => (true|false)
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
- ruby_xml_attr_t *rxa;
333
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
334
- if (rxa->attr->prev == NULL)
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! => nil
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
- ruby_xml_attr_t *rxa;
350
- Data_Get_Struct(self, ruby_xml_attr_t, rxa);
351
- xmlUnlinkNode(rxa->attr);
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 => "value"
419
+ * attr.value -> "value"
358
420
  *
359
421
  * Obtain the value of this attribute.
360
422
  */
361
423
  VALUE
362
- ruby_xml_attr_value(VALUE self) {
363
- ruby_xml_attr_t *rxa;
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, ruby_xml_attr_t, rxa);
429
+ Data_Get_Struct(self, xmlAttr, xattr);
368
430
  if (ruby_xml_attr_parent_q(self) == Qtrue) {
369
- value = xmlGetProp(rxa->attr->parent, rxa->attr->name);
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", ruby_xml_attr_value, 0);
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
  }