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.
- data/CHANGELOG +6 -0
- data/LICENSE +1 -1
- data/README +1 -1
- data/Rakefile +8 -5
- data/TODO +1 -1
- data/ext/xml/extconf.rb +4 -5
- data/ext/xml/libxml.c +5 -2
- data/ext/xml/libxml.h +16 -7
- data/ext/xml/libxml.rb +3 -3
- data/ext/xml/ruby_xml_attr.c +118 -99
- data/ext/xml/ruby_xml_attr.h +4 -7
- data/ext/xml/ruby_xml_document.c +131 -170
- data/ext/xml/ruby_xml_document.h +5 -9
- data/ext/xml/ruby_xml_html_parser.c +453 -0
- data/ext/xml/ruby_xml_html_parser.h +29 -0
- data/ext/xml/ruby_xml_node.c +219 -253
- data/ext/xml/ruby_xml_node.h +4 -7
- data/ext/xml/ruby_xml_node_set.c +6 -6
- data/ext/xml/ruby_xml_node_set.h +1 -1
- data/ext/xml/ruby_xml_ns.c +1 -1
- data/ext/xml/ruby_xml_ns.h +1 -1
- data/ext/xml/ruby_xml_parser.c +5 -8
- data/ext/xml/ruby_xml_parser.h +1 -1
- data/ext/xml/ruby_xml_parser_context.c +3 -4
- data/ext/xml/ruby_xml_parser_context.h +1 -1
- data/ext/xml/ruby_xml_reader.c +893 -0
- data/ext/xml/ruby_xml_reader.h +14 -0
- data/ext/xml/ruby_xml_sax_parser.c +255 -204
- data/ext/xml/ruby_xml_sax_parser.h +6 -2
- data/ext/xml/ruby_xml_tree.c +1 -1
- data/ext/xml/ruby_xml_tree.h +1 -1
- data/ext/xml/ruby_xml_xinclude.c +1 -1
- data/ext/xml/ruby_xml_xinclude.h +1 -1
- data/ext/xml/ruby_xml_xpath.c +3 -2
- data/ext/xml/ruby_xml_xpath.h +1 -1
- data/ext/xml/ruby_xml_xpath_context.c +4 -4
- data/ext/xml/ruby_xml_xpath_context.h +1 -1
- data/ext/xml/ruby_xml_xpointer.c +10 -4
- data/ext/xml/ruby_xml_xpointer.h +1 -1
- data/ext/xml/ruby_xml_xpointer_context.c +1 -1
- data/ext/xml/ruby_xml_xpointer_context.h +1 -1
- data/ext/xml/sax_parser_callbacks.inc +55 -54
- data/tests/model/rubynet_project +1 -1
- data/tests/model/simple.xml +7 -0
- data/tests/tc_xml_document.rb +1 -1
- data/tests/tc_xml_document_write.rb +1 -1
- data/tests/tc_xml_document_write2.rb +1 -1
- data/tests/tc_xml_document_write3.rb +1 -1
- data/tests/tc_xml_html_parser.rb +60 -0
- data/tests/tc_xml_node.rb +1 -1
- data/tests/tc_xml_node2.rb +1 -1
- data/tests/tc_xml_node3.rb +1 -1
- data/tests/tc_xml_node4.rb +8 -5
- data/tests/tc_xml_node5.rb +1 -1
- data/tests/tc_xml_node6.rb +1 -1
- data/tests/tc_xml_node7.rb +1 -1
- data/tests/tc_xml_node_set.rb +1 -1
- data/tests/tc_xml_node_set2.rb +1 -1
- data/tests/tc_xml_node_xlink.rb +1 -1
- data/tests/tc_xml_parser.rb +5 -1
- data/tests/tc_xml_parser2.rb +1 -1
- data/tests/tc_xml_parser3.rb +1 -1
- data/tests/tc_xml_parser4.rb +1 -1
- data/tests/tc_xml_parser5.rb +1 -1
- data/tests/tc_xml_parser6.rb +1 -1
- data/tests/tc_xml_parser7.rb +1 -1
- data/tests/tc_xml_parser8.rb +1 -1
- data/tests/tc_xml_parser_context.rb +1 -1
- data/tests/tc_xml_reader.rb +101 -0
- data/tests/tc_xml_sax_parser.rb +95 -0
- data/tests/tc_xml_xinclude.rb +1 -1
- data/tests/tc_xml_xpath.rb +1 -1
- data/tests/tc_xml_xpointer.rb +1 -1
- metadata +79 -73
- data/ext/xml/ruby_xml_attribute.c +0 -224
- data/ext/xml/ruby_xml_attribute.h +0 -21
- data/tests/test_xml_sax_parser.rb +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_sax_parser.h
|
|
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;
|
data/ext/xml/ruby_xml_tree.c
CHANGED
data/ext/xml/ruby_xml_tree.h
CHANGED
data/ext/xml/ruby_xml_xinclude.c
CHANGED
data/ext/xml/ruby_xml_xinclude.h
CHANGED
data/ext/xml/ruby_xml_xpath.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpath.c
|
|
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->
|
|
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");
|
data/ext/xml/ruby_xml_xpath.h
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpath_context.c
|
|
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
|
-
|
|
64
|
+
ruby_xml_document_t *rxd;
|
|
65
65
|
xmlXPathContextPtr ctxt;
|
|
66
66
|
|
|
67
|
-
Data_Get_Struct(xd,
|
|
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
|
|
84
|
+
return ruby_xml_xpath_context_new3(ruby_xml_document_wrap(cXMLDocument,node->node->doc));
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
|
data/ext/xml/ruby_xml_xpointer.c
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpointer.c
|
|
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,
|
|
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,
|
|
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,
|
|
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");
|
data/ext/xml/ruby_xml_xpointer.h
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/* $Id: sax_parser_callbacks.inc
|
|
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(
|
|
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->
|
|
12
|
+
VALUE handler = cbp->callbackHandler;
|
|
13
13
|
|
|
14
14
|
if (handler && handler != Qnil) {
|
|
15
|
-
rb_funcall(handler,
|
|
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(
|
|
21
|
-
VALUE handler = cbp->
|
|
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,
|
|
24
|
+
rb_funcall(handler,cbidOnIsStandalone,0);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static void has_internal_subset_func(
|
|
29
|
-
VALUE handler = cbp->
|
|
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,
|
|
32
|
+
rb_funcall(handler,cbidOnHasInternalSubset,0);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
static void has_external_subset_func(
|
|
37
|
-
VALUE handler = cbp->
|
|
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,
|
|
40
|
+
rb_funcall(handler,cbidOnHasExternalSubset,0);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
static void start_document_func(
|
|
45
|
-
VALUE handler = cbp->
|
|
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,
|
|
48
|
+
rb_funcall(handler,cbidOnStartDocument,0);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
static void end_document_func(
|
|
53
|
-
VALUE handler = cbp->
|
|
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,
|
|
56
|
+
rb_funcall(handler,cbidOnEndDocument,0);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
static void start_element_func(
|
|
60
|
+
static void start_element_func(ruby_xml_sax_parser *cbp,
|
|
61
61
|
const char *name, const char **attrs) {
|
|
62
|
-
VALUE handler = cbp->
|
|
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,
|
|
74
|
+
rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
static void end_element_func(
|
|
78
|
+
static void end_element_func(ruby_xml_sax_parser *cbp,
|
|
79
79
|
const char *name) {
|
|
80
|
-
VALUE handler = cbp->
|
|
80
|
+
VALUE handler = cbp->callbackHandler;
|
|
81
81
|
|
|
82
82
|
if (handler && handler != Qnil) {
|
|
83
|
-
rb_funcall(handler,
|
|
83
|
+
rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
static void reference_func(
|
|
87
|
+
static void reference_func(ruby_xml_sax_parser *cbp,
|
|
88
88
|
const char *name) {
|
|
89
|
-
VALUE handler = cbp->
|
|
89
|
+
VALUE handler = cbp->callbackHandler;
|
|
90
90
|
|
|
91
91
|
if (handler && handler != Qnil) {
|
|
92
|
-
rb_funcall(handler,
|
|
92
|
+
rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
static void characters_func(
|
|
96
|
+
static void characters_func(ruby_xml_sax_parser *cbp,
|
|
97
97
|
const char *chars, int len) {
|
|
98
|
-
VALUE handler = cbp->
|
|
98
|
+
VALUE handler = cbp->callbackHandler;
|
|
99
99
|
|
|
100
100
|
if (handler && handler != Qnil) {
|
|
101
|
-
rb_funcall(handler,
|
|
101
|
+
rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
static void processing_instruction_func(
|
|
105
|
+
static void processing_instruction_func(ruby_xml_sax_parser *cbp,
|
|
106
106
|
const char *target, const char *data) {
|
|
107
|
-
VALUE handler = cbp->
|
|
107
|
+
VALUE handler = cbp->callbackHandler;
|
|
108
108
|
|
|
109
109
|
if (handler && handler != Qnil) {
|
|
110
|
-
rb_funcall(handler,
|
|
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(
|
|
115
|
+
static void comment_func(ruby_xml_sax_parser *cbp,
|
|
116
116
|
const char *msg) {
|
|
117
|
-
VALUE handler = cbp->
|
|
117
|
+
VALUE handler = cbp->callbackHandler;
|
|
118
118
|
|
|
119
119
|
if (handler && handler != Qnil) {
|
|
120
|
-
rb_funcall(handler,
|
|
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
|
-
|
|
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->
|
|
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(
|
|
145
|
+
static void error_func(ruby_xml_sax_parser *cbp,
|
|
145
146
|
const char *msg, ...) {
|
|
146
|
-
VALUE handler = cbp->
|
|
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(
|
|
154
|
+
static void fatal_error_func(ruby_xml_sax_parser *cbp,
|
|
154
155
|
const char *msg, ...) {
|
|
155
|
-
VALUE handler = cbp->
|
|
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(
|
|
163
|
+
static void cdata_block_func(ruby_xml_sax_parser *cbp,
|
|
163
164
|
const char *value, int len) {
|
|
164
|
-
VALUE handler = cbp->
|
|
165
|
+
VALUE handler = cbp->callbackHandler;
|
|
165
166
|
|
|
166
167
|
if (handler && handler != Qnil) {
|
|
167
|
-
rb_funcall(handler,
|
|
168
|
+
rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
static void external_subset_func(
|
|
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->
|
|
176
|
+
VALUE handler = cbp->callbackHandler;
|
|
176
177
|
|
|
177
178
|
if (handler && handler != Qnil) {
|
|
178
|
-
rb_funcall(handler,
|
|
179
|
+
rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
|
|
179
180
|
rb_str_new2(extid), rb_str_new2(sysid));
|
|
180
181
|
}
|
|
181
182
|
}
|
data/tests/model/rubynet_project
CHANGED
data/tests/tc_xml_document.rb
CHANGED
|
@@ -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
data/tests/tc_xml_node2.rb
CHANGED
data/tests/tc_xml_node3.rb
CHANGED
data/tests/tc_xml_node4.rb
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
# $Id: tc_xml_node4.rb
|
|
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
|
data/tests/tc_xml_node5.rb
CHANGED
data/tests/tc_xml_node6.rb
CHANGED
data/tests/tc_xml_node7.rb
CHANGED
data/tests/tc_xml_node_set.rb
CHANGED
data/tests/tc_xml_node_set2.rb
CHANGED
data/tests/tc_xml_node_xlink.rb
CHANGED
data/tests/tc_xml_parser.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# $Id: tc_xml_parser.rb
|
|
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()
|
data/tests/tc_xml_parser2.rb
CHANGED
data/tests/tc_xml_parser3.rb
CHANGED