libxml-ruby 0.3.8.4 → 0.5.0

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.
Files changed (77) hide show
  1. data/CHANGELOG +6 -0
  2. data/LICENSE +1 -1
  3. data/README +1 -1
  4. data/Rakefile +8 -5
  5. data/TODO +1 -1
  6. data/ext/xml/extconf.rb +4 -5
  7. data/ext/xml/libxml.c +5 -2
  8. data/ext/xml/libxml.h +16 -7
  9. data/ext/xml/libxml.rb +3 -3
  10. data/ext/xml/ruby_xml_attr.c +118 -99
  11. data/ext/xml/ruby_xml_attr.h +4 -7
  12. data/ext/xml/ruby_xml_document.c +131 -170
  13. data/ext/xml/ruby_xml_document.h +5 -9
  14. data/ext/xml/ruby_xml_html_parser.c +453 -0
  15. data/ext/xml/ruby_xml_html_parser.h +29 -0
  16. data/ext/xml/ruby_xml_node.c +219 -253
  17. data/ext/xml/ruby_xml_node.h +4 -7
  18. data/ext/xml/ruby_xml_node_set.c +6 -6
  19. data/ext/xml/ruby_xml_node_set.h +1 -1
  20. data/ext/xml/ruby_xml_ns.c +1 -1
  21. data/ext/xml/ruby_xml_ns.h +1 -1
  22. data/ext/xml/ruby_xml_parser.c +5 -8
  23. data/ext/xml/ruby_xml_parser.h +1 -1
  24. data/ext/xml/ruby_xml_parser_context.c +3 -4
  25. data/ext/xml/ruby_xml_parser_context.h +1 -1
  26. data/ext/xml/ruby_xml_reader.c +893 -0
  27. data/ext/xml/ruby_xml_reader.h +14 -0
  28. data/ext/xml/ruby_xml_sax_parser.c +255 -204
  29. data/ext/xml/ruby_xml_sax_parser.h +6 -2
  30. data/ext/xml/ruby_xml_tree.c +1 -1
  31. data/ext/xml/ruby_xml_tree.h +1 -1
  32. data/ext/xml/ruby_xml_xinclude.c +1 -1
  33. data/ext/xml/ruby_xml_xinclude.h +1 -1
  34. data/ext/xml/ruby_xml_xpath.c +3 -2
  35. data/ext/xml/ruby_xml_xpath.h +1 -1
  36. data/ext/xml/ruby_xml_xpath_context.c +4 -4
  37. data/ext/xml/ruby_xml_xpath_context.h +1 -1
  38. data/ext/xml/ruby_xml_xpointer.c +10 -4
  39. data/ext/xml/ruby_xml_xpointer.h +1 -1
  40. data/ext/xml/ruby_xml_xpointer_context.c +1 -1
  41. data/ext/xml/ruby_xml_xpointer_context.h +1 -1
  42. data/ext/xml/sax_parser_callbacks.inc +55 -54
  43. data/tests/model/rubynet_project +1 -1
  44. data/tests/model/simple.xml +7 -0
  45. data/tests/tc_xml_document.rb +1 -1
  46. data/tests/tc_xml_document_write.rb +1 -1
  47. data/tests/tc_xml_document_write2.rb +1 -1
  48. data/tests/tc_xml_document_write3.rb +1 -1
  49. data/tests/tc_xml_html_parser.rb +60 -0
  50. data/tests/tc_xml_node.rb +1 -1
  51. data/tests/tc_xml_node2.rb +1 -1
  52. data/tests/tc_xml_node3.rb +1 -1
  53. data/tests/tc_xml_node4.rb +8 -5
  54. data/tests/tc_xml_node5.rb +1 -1
  55. data/tests/tc_xml_node6.rb +1 -1
  56. data/tests/tc_xml_node7.rb +1 -1
  57. data/tests/tc_xml_node_set.rb +1 -1
  58. data/tests/tc_xml_node_set2.rb +1 -1
  59. data/tests/tc_xml_node_xlink.rb +1 -1
  60. data/tests/tc_xml_parser.rb +5 -1
  61. data/tests/tc_xml_parser2.rb +1 -1
  62. data/tests/tc_xml_parser3.rb +1 -1
  63. data/tests/tc_xml_parser4.rb +1 -1
  64. data/tests/tc_xml_parser5.rb +1 -1
  65. data/tests/tc_xml_parser6.rb +1 -1
  66. data/tests/tc_xml_parser7.rb +1 -1
  67. data/tests/tc_xml_parser8.rb +1 -1
  68. data/tests/tc_xml_parser_context.rb +1 -1
  69. data/tests/tc_xml_reader.rb +101 -0
  70. data/tests/tc_xml_sax_parser.rb +95 -0
  71. data/tests/tc_xml_xinclude.rb +1 -1
  72. data/tests/tc_xml_xpath.rb +1 -1
  73. data/tests/tc_xml_xpointer.rb +1 -1
  74. metadata +79 -73
  75. data/ext/xml/ruby_xml_attribute.c +0 -224
  76. data/ext/xml/ruby_xml_attribute.h +0 -21
  77. data/tests/test_xml_sax_parser.rb +0 -64
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_sax_parser.h,v 1.2 2006/04/14 14:45:52 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_sax_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -6,7 +6,9 @@
6
6
  #define __RUBY_XML_SAX_PARSER__
7
7
 
8
8
  extern VALUE cXMLSaxParser;
9
+ extern VALUE mXMLSaxParserCallbacks;
9
10
 
11
+ /*
10
12
  typedef struct ruby_xml_sax_parser_callbacks {
11
13
  VALUE internalSubset;
12
14
  VALUE isStandalone;
@@ -36,11 +38,13 @@ typedef struct ruby_xml_sax_parser_callbacks {
36
38
  VALUE cdataBlock;
37
39
  VALUE externalSubset;
38
40
  } ruby_xml_sax_parser_callbacks;
41
+ */
39
42
 
40
43
  typedef struct ruby_xml_sax_parser {
41
44
  xmlParserCtxtPtr xpc;
42
45
  xmlSAXHandlerPtr xsh;
43
- ruby_xml_sax_parser_callbacks *cbp;
46
+ //ruby_xml_sax_parser_callbacks *cbp;
47
+ VALUE callbackHandler;
44
48
  VALUE filename;
45
49
  VALUE str;
46
50
  } ruby_xml_sax_parser;
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_tree.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_tree.c 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_tree.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_tree.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xinclude.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xinclude.c 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xinclude.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xinclude.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath.c,v 1.2.4.1 2006/11/26 12:37:41 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpath.c 138 2007-08-29 18:00:35Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -226,7 +226,8 @@ ruby_xml_xpath_find(int argc, VALUE *argv, VALUE class) {
226
226
  if (rxxp->xpop->type != XPATH_NODESET)
227
227
  return(Qnil);
228
228
 
229
- return(ruby_xml_node_set_new2(node->xd, xpath,
229
+ return(ruby_xml_node_set_new2(ruby_xml_document_wrap(cXMLDocument,node->node->doc),
230
+ xpath,
230
231
  rxxp->xpop->nodesetval));
231
232
  #else
232
233
  rb_warn("libxml was compiled without XPath support");
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpath.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath_context.c,v 1.2 2006/02/27 12:55:32 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpath_context.c 138 2007-08-29 18:00:35Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -61,10 +61,10 @@ ruby_xml_xpath_context_new2(VALUE xd, xmlXPathContextPtr xxpc) {
61
61
 
62
62
  VALUE
63
63
  ruby_xml_xpath_context_new3(VALUE xd) {
64
- ruby_xml_document *rxd;
64
+ ruby_xml_document_t *rxd;
65
65
  xmlXPathContextPtr ctxt;
66
66
 
67
- Data_Get_Struct(xd, ruby_xml_document, rxd);
67
+ Data_Get_Struct(xd, ruby_xml_document_t, rxd);
68
68
  if (rxd->doc == NULL)
69
69
  return(Qnil);
70
70
 
@@ -81,7 +81,7 @@ ruby_xml_xpath_context_new4(VALUE rnode) {
81
81
  ruby_xml_node *node;
82
82
 
83
83
  Data_Get_Struct(rnode, ruby_xml_node, node);
84
- return(ruby_xml_xpath_context_new3(node->xd));
84
+ return ruby_xml_xpath_context_new3(ruby_xml_document_wrap(cXMLDocument,node->node->doc));
85
85
  }
86
86
 
87
87
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath_context.h,v 1.2 2006/02/27 12:55:32 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpath_context.h 41 2006-02-27 12:55:32Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer.c,v 1.1.4.1 2006/11/26 12:37:42 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpointer.c 138 2007-08-29 18:00:35Z danj $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -22,7 +22,8 @@ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
22
22
 
23
23
  Data_Get_Struct(rnode, ruby_xml_node, node);
24
24
 
25
- rxptr_xpth_ctxt = ruby_xml_xpath_context_new(cXMLXPathContext, node->xd,
25
+ rxptr_xpth_ctxt = ruby_xml_xpath_context_new(cXMLXPathContext,
26
+ ruby_xml_document_wrap(cXMLDocument,node->node->doc),
26
27
  xmlXPtrNewContext(node->node->doc, node->node, NULL));
27
28
  if (NIL_P(rxptr_xpth_ctxt))
28
29
  return(Qnil);
@@ -32,7 +33,10 @@ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
32
33
  if (xpath == NULL)
33
34
  rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
34
35
 
35
- rxxp = ruby_xml_xpath_new(cXMLXPath, node->xd, rxptr_xpth_ctxt, xpath);
36
+ rxxp = ruby_xml_xpath_new(cXMLXPath,
37
+ ruby_xml_document_wrap(cXMLDocument,node->node->doc),
38
+ rxptr_xpth_ctxt
39
+ , xpath);
36
40
  return(rxxp);
37
41
  #else
38
42
  rb_warn("libxml was compiled without XPointer support");
@@ -78,7 +82,9 @@ ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
78
82
  if (xpath == NULL)
79
83
  rb_fatal("You shouldn't be able to have this happen");
80
84
 
81
- rxxp = ruby_xml_xpath_new(cXMLXPath, start->xd, Qnil, xpath);
85
+ rxxp = ruby_xml_xpath_new(cXMLXPath,
86
+ ruby_xml_document_wrap(cXMLDocument,start->node->doc),
87
+ Qnil, xpath);
82
88
  return(rxxp);
83
89
  #else
84
90
  rb_warn("libxml was compiled without XPointer support");
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpointer.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer_context.c,v 1.2.4.1 2006/11/26 12:37:42 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpointer_context.c 120 2006-11-26 12:57:56Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer_context.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
1
+ /* $Id: ruby_xml_xpointer_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -1,65 +1,65 @@
1
- /* $Id: sax_parser_callbacks.inc,v 1.1.4.1 2006/11/26 12:45:14 roscopeco Exp $ */
1
+ /* $Id: sax_parser_callbacks.inc 120 2006-11-26 12:57:56Z roscopeco $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
5
  /*
6
6
  * SAX CALLBACK HANDLERS
7
7
  */
8
- static void internal_subset_func(ruby_xml_sax_parser_callbacks *cbp,
8
+ static void internal_subset_func(ruby_xml_sax_parser *cbp,
9
9
  const char *name,
10
10
  const char *extid,
11
11
  const char *sysid) {
12
- VALUE handler = cbp->internalSubset;
12
+ VALUE handler = cbp->callbackHandler;
13
13
 
14
14
  if (handler && handler != Qnil) {
15
- rb_funcall(handler, callsym, 3, rb_str_new2(name),
15
+ rb_funcall(handler, cbidOnInternalSubset, 3, rb_str_new2(name),
16
16
  rb_str_new2(extid), rb_str_new2(sysid));
17
17
  }
18
18
  }
19
19
 
20
- static void is_standalone_func(ruby_xml_sax_parser_callbacks *cbp) {
21
- VALUE handler = cbp->isStandalone;
20
+ static void is_standalone_func(ruby_xml_sax_parser *cbp) {
21
+ VALUE handler = cbp->callbackHandler;
22
22
 
23
23
  if (handler && handler != Qnil) {
24
- rb_funcall(handler,callsym,0);
24
+ rb_funcall(handler,cbidOnIsStandalone,0);
25
25
  }
26
26
  }
27
27
 
28
- static void has_internal_subset_func(ruby_xml_sax_parser_callbacks *cbp) {
29
- VALUE handler = cbp->hasInternalSubset;
28
+ static void has_internal_subset_func(ruby_xml_sax_parser *cbp) {
29
+ VALUE handler = cbp->callbackHandler;
30
30
 
31
31
  if (handler && handler != Qnil) {
32
- rb_funcall(handler,callsym,0);
32
+ rb_funcall(handler,cbidOnHasInternalSubset,0);
33
33
  }
34
34
  }
35
35
 
36
- static void has_external_subset_func(ruby_xml_sax_parser_callbacks *cbp) {
37
- VALUE handler = cbp->hasExternalSubset;
36
+ static void has_external_subset_func(ruby_xml_sax_parser *cbp) {
37
+ VALUE handler = cbp->callbackHandler;
38
38
 
39
39
  if (handler && handler != Qnil) {
40
- rb_funcall(handler,callsym,0);
40
+ rb_funcall(handler,cbidOnHasExternalSubset,0);
41
41
  }
42
42
  }
43
43
 
44
- static void start_document_func(ruby_xml_sax_parser_callbacks *cbp) {
45
- VALUE handler = cbp->startDocument;
44
+ static void start_document_func(ruby_xml_sax_parser *cbp) {
45
+ VALUE handler = cbp->callbackHandler;
46
46
 
47
47
  if (handler && handler != Qnil) {
48
- rb_funcall(handler,callsym,0);
48
+ rb_funcall(handler,cbidOnStartDocument,0);
49
49
  }
50
50
  }
51
51
 
52
- static void end_document_func(ruby_xml_sax_parser_callbacks *cbp) {
53
- VALUE handler = cbp->endDocument;
52
+ static void end_document_func(ruby_xml_sax_parser *cbp) {
53
+ VALUE handler = cbp->callbackHandler;
54
54
 
55
55
  if (handler && handler != Qnil) {
56
- rb_funcall(handler,callsym,0);
56
+ rb_funcall(handler,cbidOnEndDocument,0);
57
57
  }
58
58
  }
59
59
 
60
- static void start_element_func(ruby_xml_sax_parser_callbacks *cbp,
60
+ static void start_element_func(ruby_xml_sax_parser *cbp,
61
61
  const char *name, const char **attrs) {
62
- VALUE handler = cbp->startElement;
62
+ VALUE handler = cbp->callbackHandler;
63
63
  VALUE ahsh = rb_hash_new();
64
64
  const char *attr, *value;
65
65
 
@@ -71,57 +71,57 @@ static void start_element_func(ruby_xml_sax_parser_callbacks *cbp,
71
71
  }
72
72
 
73
73
  if (handler && handler != Qnil) {
74
- rb_funcall(handler,callsym,2,rb_str_new2(name),ahsh);
74
+ rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
75
75
  }
76
76
  }
77
77
 
78
- static void end_element_func(ruby_xml_sax_parser_callbacks *cbp,
78
+ static void end_element_func(ruby_xml_sax_parser *cbp,
79
79
  const char *name) {
80
- VALUE handler = cbp->endElement;
80
+ VALUE handler = cbp->callbackHandler;
81
81
 
82
82
  if (handler && handler != Qnil) {
83
- rb_funcall(handler,callsym,1,rb_str_new2(name));
83
+ rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
84
84
  }
85
85
  }
86
86
 
87
- static void reference_func(ruby_xml_sax_parser_callbacks *cbp,
87
+ static void reference_func(ruby_xml_sax_parser *cbp,
88
88
  const char *name) {
89
- VALUE handler = cbp->reference;
89
+ VALUE handler = cbp->callbackHandler;
90
90
 
91
91
  if (handler && handler != Qnil) {
92
- rb_funcall(handler,callsym,1,rb_str_new2(name));
92
+ rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
93
93
  }
94
94
  }
95
95
 
96
- static void characters_func(ruby_xml_sax_parser_callbacks *cbp,
96
+ static void characters_func(ruby_xml_sax_parser *cbp,
97
97
  const char *chars, int len) {
98
- VALUE handler = cbp->characters;
98
+ VALUE handler = cbp->callbackHandler;
99
99
 
100
100
  if (handler && handler != Qnil) {
101
- rb_funcall(handler,callsym,1,rb_str_new(chars, len));
101
+ rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
102
102
  }
103
103
  }
104
104
 
105
- static void processing_instruction_func(ruby_xml_sax_parser_callbacks *cbp,
105
+ static void processing_instruction_func(ruby_xml_sax_parser *cbp,
106
106
  const char *target, const char *data) {
107
- VALUE handler = cbp->processingInstruction;
107
+ VALUE handler = cbp->callbackHandler;
108
108
 
109
109
  if (handler && handler != Qnil) {
110
- rb_funcall(handler, callsym, 2,
110
+ rb_funcall(handler, cbidOnProcessingInstruction, 2,
111
111
  rb_str_new2(target),rb_str_new2(data));
112
112
  }
113
113
  }
114
114
 
115
- static void comment_func(ruby_xml_sax_parser_callbacks *cbp,
115
+ static void comment_func(ruby_xml_sax_parser *cbp,
116
116
  const char *msg) {
117
- VALUE handler = cbp->comment;
117
+ VALUE handler = cbp->callbackHandler;
118
118
 
119
119
  if (handler && handler != Qnil) {
120
- rb_funcall(handler,callsym,1,rb_str_new2(msg));
120
+ rb_funcall(handler,cbidOnComment,1,rb_str_new2(msg));
121
121
  }
122
122
  }
123
123
 
124
- #define FORMAT_AND_CALL() \
124
+ #define FORMAT_AND_CALL(callsym) \
125
125
  do { \
126
126
  va_list args; \
127
127
  char buf[1024]; \
@@ -131,51 +131,52 @@ static void comment_func(ruby_xml_sax_parser_callbacks *cbp,
131
131
  va_end(args); \
132
132
  } \
133
133
  while (0)
134
-
135
- static void warning_func(ruby_xml_sax_parser_callbacks *cbp,
134
+
135
+ // TODO these next three should actually be formatting messages.
136
+ static void warning_func(ruby_xml_sax_parser *cbp,
136
137
  const char *msg, ...) {
137
- VALUE handler = cbp->xmlParserWarning;
138
+ VALUE handler = cbp->callbackHandler;
138
139
 
139
140
  if (handler && handler != Qnil) {
140
- FORMAT_AND_CALL();
141
+ FORMAT_AND_CALL(cbidOnXmlParserWarning);
141
142
  }
142
143
  }
143
144
 
144
- static void error_func(ruby_xml_sax_parser_callbacks *cbp,
145
+ static void error_func(ruby_xml_sax_parser *cbp,
145
146
  const char *msg, ...) {
146
- VALUE handler = cbp->xmlParserError;
147
+ VALUE handler = cbp->callbackHandler;
147
148
 
148
149
  if (handler && handler != Qnil) {
149
- FORMAT_AND_CALL();
150
+ FORMAT_AND_CALL(cbidOnXmlParserError);
150
151
  }
151
152
  }
152
153
 
153
- static void fatal_error_func(ruby_xml_sax_parser_callbacks *cbp,
154
+ static void fatal_error_func(ruby_xml_sax_parser *cbp,
154
155
  const char *msg, ...) {
155
- VALUE handler = cbp->xmlParserFatalError;
156
+ VALUE handler = cbp->callbackHandler;
156
157
 
157
158
  if (handler && handler != Qnil) {
158
- FORMAT_AND_CALL();
159
+ FORMAT_AND_CALL(cbidOnXmlParserFatalError);
159
160
  }
160
161
  }
161
162
 
162
- static void cdata_block_func(ruby_xml_sax_parser_callbacks *cbp,
163
+ static void cdata_block_func(ruby_xml_sax_parser *cbp,
163
164
  const char *value, int len) {
164
- VALUE handler = cbp->cdataBlock;
165
+ VALUE handler = cbp->callbackHandler;
165
166
 
166
167
  if (handler && handler != Qnil) {
167
- rb_funcall(handler,callsym,1,rb_str_new(value, len));
168
+ rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
168
169
  }
169
170
  }
170
171
 
171
- static void external_subset_func(ruby_xml_sax_parser_callbacks *cbp,
172
+ static void external_subset_func(ruby_xml_sax_parser *cbp,
172
173
  const char *name,
173
174
  const char *extid,
174
175
  const char *sysid) {
175
- VALUE handler = cbp->externalSubset;
176
+ VALUE handler = cbp->callbackHandler;
176
177
 
177
178
  if (handler && handler != Qnil) {
178
- rb_funcall(handler, callsym, 3, rb_str_new2(name),
179
+ rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
179
180
  rb_str_new2(extid), rb_str_new2(sysid));
180
181
  }
181
182
  }
@@ -1,4 +1,4 @@
1
- # $Id: rubynet_project,v 1.1 2005/12/19 19:53:07 roscopeco Exp $
1
+ # $Id: rubynet_project 26 2005-12-19 19:53:07Z roscopeco $
2
2
 
3
3
  copyright: 2001-2003, rubynet.org
4
4
  description: Ruby bindings for the libxml2 library. The API for this
@@ -0,0 +1,7 @@
1
+ <root>
2
+ <foo>123</foo>
3
+ <bar x='1' y='2'>
4
+ <fuga>test1</fuga>
5
+ <fuga>test2</fuga>
6
+ </bar>
7
+ </root>
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_document.rb,v 1.3 2006/04/17 13:30:20 roscopeco Exp $
1
+ # $Id: tc_xml_document.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require 'test/unit'
3
3
  require "libxml_test"
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_document_write.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
1
+ # $Id: tc_xml_document_write.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_document_write2.rb,v 1.3 2006/04/17 13:30:18 roscopeco Exp $
1
+ # $Id: tc_xml_document_write2.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_document_write3.rb,v 1.4 2006/11/20 01:22:08 roscopeco Exp $
1
+ # $Id: tc_xml_document_write3.rb 107 2006-11-20 01:22:08Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -0,0 +1,60 @@
1
+ # $Id: tc_xml_html_parser.rb 111 2006-11-20 01:39:14Z roscopeco $
2
+ require "libxml_test"
3
+ require 'test/unit'
4
+
5
+ class TC_XML_HTMLParser < Test::Unit::TestCase
6
+ def setup()
7
+ @xp = XML::HTMLParser.new()
8
+ assert_not_nil(@xp)
9
+ str = '<html><head><meta name=keywords content=nasty></head><body>Hello<br>World</html>'
10
+ @xp.string = str
11
+ assert_equal(str, @xp.string)
12
+ end
13
+
14
+ def teardown()
15
+ @xp = nil
16
+ end
17
+
18
+ def test_libxml_html_parser_parse()
19
+ doc = @xp.parse
20
+
21
+ assert_instance_of XML::Document, doc
22
+
23
+ root = doc.root
24
+ assert_instance_of XML::Node, root
25
+ assert_equal 'html', root.name
26
+
27
+ head = root.child
28
+ assert_instance_of XML::Node, head
29
+ assert_equal 'head', head.name
30
+
31
+ meta = head.child
32
+ assert_instance_of XML::Node, meta
33
+ assert_equal 'meta', meta.name
34
+ assert_equal 'keywords', meta[:name]
35
+ assert_equal 'nasty', meta[:content]
36
+
37
+ body = head.next
38
+ assert_instance_of XML::Node, body
39
+ assert_equal 'body', body.name
40
+
41
+ hello = body.child
42
+ assert_instance_of XML::Node, hello
43
+ assert_equal 'Hello', hello.content
44
+
45
+ br = hello.next
46
+ assert_instance_of XML::Node, br
47
+ assert_equal 'br', br.name
48
+
49
+ world = br.next
50
+ assert_instance_of XML::Node, world
51
+ assert_equal 'World', world.content
52
+ end
53
+
54
+ def test_libxml_html_parser_parser_context()
55
+ doc = @xp.parse
56
+ assert_instance_of(XML::Document, doc)
57
+ assert_instance_of(XML::Parser::Context, @xp.parser_context)
58
+ assert @xp.parser_context.html?
59
+ end
60
+ end # TC_XML_HTMLParser
data/tests/tc_xml_node.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
1
+ # $Id: tc_xml_node.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node2.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
1
+ # $Id: tc_xml_node2.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node3.rb,v 1.3 2006/11/20 01:22:08 roscopeco Exp $
1
+ # $Id: tc_xml_node3.rb 107 2006-11-20 01:22:08Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,13 +1,16 @@
1
- # $Id: tc_xml_node4.rb,v 1.3 2006/05/10 18:02:51 roscopeco Exp $
1
+ # $Id: tc_xml_node4.rb 142 2007-08-29 18:56:22Z danj $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
5
5
  class TC_XML_Node4 < Test::Unit::TestCase
6
6
  def setup()
7
7
  xp = XML::Parser.new()
8
- str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
9
- assert_equal(str, xp.string = str)
8
+ @str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
9
+ assert_equal(@str, xp.string = @str)
10
10
  doc = xp.parse
11
+ xp2=XML::Parser.new()
12
+ xp2.string=@str
13
+ @doc2 = xp2.parse
11
14
  assert_instance_of(XML::Document, doc)
12
15
  assert_instance_of(XML::Node, doc.root)
13
16
  @root = doc.root
@@ -20,7 +23,7 @@ class TC_XML_Node4 < Test::Unit::TestCase
20
23
 
21
24
  def test_xml_node_eql?()
22
25
  first1 = @root.child
23
- first2 = @root.child
26
+ first2 = @doc2.root.child
24
27
 
25
28
  assert_not_equal first1.object_id, first2.object_id
26
29
  assert first1.eql?(first2)
@@ -31,7 +34,7 @@ class TC_XML_Node4 < Test::Unit::TestCase
31
34
 
32
35
  def test_xml_node_hash()
33
36
  first1 = @root.child
34
- first2 = @root.child
37
+ first2 = @doc2.root.child
35
38
 
36
39
  assert_not_equal first1.object_id, first2.object_id
37
40
  assert_equal first1.hash, first2.hash
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node5.rb,v 1.1 2006/05/10 18:03:57 roscopeco Exp $
1
+ # $Id: tc_xml_node5.rb 78 2006-05-10 18:03:57Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node6.rb,v 1.2 2006/05/31 17:26:43 roscopeco Exp $
1
+ # $Id: tc_xml_node6.rb 81 2006-05-31 17:26:43Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node7.rb,v 1.2.2.1 2006/11/27 10:32:01 roscopeco Exp $
1
+ # $Id: tc_xml_node7.rb 123 2006-11-27 10:41:14Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node_set.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
1
+ # $Id: tc_xml_node_set.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node_set2.rb,v 1.3 2006/11/20 01:22:08 roscopeco Exp $
1
+ # $Id: tc_xml_node_set2.rb 107 2006-11-20 01:22:08Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_node_xlink.rb,v 1.4 2006/11/20 01:22:08 roscopeco Exp $
1
+ # $Id: tc_xml_node_xlink.rb 107 2006-11-20 01:22:08Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_parser.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
1
+ # $Id: tc_xml_parser.rb 124 2006-11-30 17:29:04Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -70,6 +70,10 @@ class TC_XML_Parser < Test::Unit::TestCase
70
70
 
71
71
  XML::Parser::default_keep_blanks = false
72
72
  assert(!XML::Parser::default_keep_blanks)
73
+
74
+ # other tests depend on keeping blanks by default,
75
+ # which is the default default behaviour anyway.
76
+ XML::Parser::default_keep_blanks = true
73
77
  end
74
78
 
75
79
  def test_ruby_xml_parser_default_line_numbers()
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_parser2.rb,v 1.3 2006/04/17 13:30:18 roscopeco Exp $
1
+ # $Id: tc_xml_parser2.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4
 
@@ -1,4 +1,4 @@
1
- # $Id: tc_xml_parser3.rb,v 1.3 2006/04/17 13:30:18 roscopeco Exp $
1
+ # $Id: tc_xml_parser3.rb 67 2006-04-17 13:30:22Z roscopeco $
2
2
  require "libxml_test"
3
3
  require 'test/unit'
4
4