1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use Test; |
4 |
wakaba |
1.10 |
BEGIN { plan tests => 2808 } |
5 |
wakaba |
1.1 |
|
6 |
|
|
require Message::DOM::DOMImplementation; |
7 |
wakaba |
1.3 |
use Message::Util::Error; |
8 |
wakaba |
1.1 |
|
9 |
|
|
my $dom = Message::DOM::DOMImplementation->____new; |
10 |
|
|
my $doc = $dom->create_document; |
11 |
|
|
|
12 |
wakaba |
1.4 |
|
13 |
|
|
sub create_nodes () { |
14 |
|
|
( |
15 |
|
|
$doc->create_attribute ('attr1'), |
16 |
|
|
$doc->create_attribute_definition ('at1'), |
17 |
|
|
$doc->create_cdata_section ('cdata1'), |
18 |
|
|
$doc->create_comment ('comment1'), |
19 |
|
|
$doc->create_element ('element1'), |
20 |
|
|
$doc->create_element_type_definition ('et1'), |
21 |
|
|
$doc->create_general_entity ('entity1'), |
22 |
|
|
$doc->create_entity_reference ('entity-reference1'), |
23 |
|
|
$doc->implementation->create_document, |
24 |
|
|
$doc->create_document_fragment, |
25 |
|
|
$doc->create_document_type_definition ('dt1'), |
26 |
|
|
$doc->create_notation ('notation1'), |
27 |
|
|
$doc->create_processing_instruction ('pi1', 'pi1data'), |
28 |
|
|
$doc->create_text_node ('text1'), |
29 |
|
|
); |
30 |
|
|
} # create_nodes |
31 |
|
|
|
32 |
|
|
sub create_parent_nodes () { |
33 |
|
|
( |
34 |
|
|
$doc->create_attribute ('attr1'), |
35 |
|
|
$doc->create_attribute_definition ('at1'), |
36 |
|
|
$doc->create_element ('element1'), |
37 |
|
|
$doc->create_general_entity ('entity1'), |
38 |
|
|
$doc->create_entity_reference ('entity-reference1'), |
39 |
|
|
$doc->implementation->create_document, |
40 |
|
|
$doc->create_document_fragment, |
41 |
|
|
$doc->create_document_type_definition ('dt1'), |
42 |
|
|
); |
43 |
|
|
} # create_parent_nodes |
44 |
|
|
|
45 |
wakaba |
1.1 |
## Constants |
46 |
|
|
my $constants = [ |
47 |
|
|
[ELEMENT_NODE => 1], |
48 |
|
|
[ATTRIBUTE_NODE => 2], |
49 |
|
|
[TEXT_NODE => 3], |
50 |
|
|
[CDATA_SECTION_NODE => 4], |
51 |
|
|
[ENTITY_REFERENCE_NODE => 5], |
52 |
|
|
[ENTITY_NODE => 6], |
53 |
|
|
[PROCESSING_INSTRUCTION_NODE => 7], |
54 |
|
|
[COMMENT_NODE => 8], |
55 |
|
|
[DOCUMENT_NODE => 9], |
56 |
|
|
[DOCUMENT_TYPE_NODE => 10], |
57 |
|
|
[DOCUMENT_FRAGMENT_NODE => 11], |
58 |
|
|
[NOTATION_NODE => 12], |
59 |
|
|
[ELEMENT_TYPE_DEFINITION_NODE => 81001], |
60 |
|
|
[ATTRIBUTE_DEFINITION_NODE => 81002], |
61 |
wakaba |
1.6 |
|
62 |
|
|
[DOCUMENT_POSITION_DISCONNECTED => 0x01], |
63 |
|
|
[DOCUMENT_POSITION_PRECEDING => 0x02], |
64 |
|
|
[DOCUMENT_POSITION_FOLLOWING => 0x04], |
65 |
|
|
[DOCUMENT_POSITION_CONTAINS => 0x08], |
66 |
|
|
[DOCUMENT_POSITION_CONTAINED_BY => 0x10], |
67 |
|
|
[DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC => 0x20], |
68 |
wakaba |
1.1 |
]; |
69 |
|
|
|
70 |
|
|
my $tests = { |
71 |
wakaba |
1.4 |
attr1 => { |
72 |
|
|
node => sub { return $doc->create_attribute ('a') }, |
73 |
|
|
attr_get => { |
74 |
|
|
manakai_attribute_type => 0, |
75 |
|
|
base_uri => undef, |
76 |
wakaba |
1.6 |
manakai_expanded_uri => 'a', |
77 |
wakaba |
1.4 |
first_child => undef, |
78 |
|
|
last_child => undef, |
79 |
|
|
local_name => 'a', |
80 |
|
|
manakai_local_name => 'a', |
81 |
|
|
namespace_uri => undef, |
82 |
|
|
next_sibling => undef, |
83 |
|
|
node_name => 'a', |
84 |
wakaba |
1.7 |
node_type => 2, |
85 |
wakaba |
1.4 |
name => 'a', |
86 |
|
|
node_value => '', |
87 |
|
|
owner_document => $doc, |
88 |
|
|
parent_node => undef, |
89 |
|
|
prefix => undef, |
90 |
|
|
previous_sibling => undef, |
91 |
|
|
value => '', |
92 |
|
|
attributes => undef, |
93 |
|
|
}, |
94 |
|
|
attr_get_bool => { |
95 |
wakaba |
1.6 |
has_attributes => 0, |
96 |
|
|
has_child_nodes => 0, |
97 |
wakaba |
1.10 |
manakai_read_only => 0, |
98 |
wakaba |
1.4 |
specified => 1, |
99 |
|
|
}, |
100 |
|
|
}, |
101 |
|
|
attr2 => { |
102 |
wakaba |
1.1 |
node => sub { |
103 |
|
|
my $attr = $doc->create_attribute ('a'); |
104 |
|
|
$attr->value ('b'); |
105 |
|
|
return $attr; |
106 |
|
|
}, |
107 |
|
|
attr_get => { |
108 |
wakaba |
1.4 |
manakai_attribute_type => 0, |
109 |
|
|
base_uri => undef, |
110 |
wakaba |
1.6 |
manakai_expanded_uri => 'a', |
111 |
wakaba |
1.2 |
local_name => 'a', |
112 |
|
|
manakai_local_name => 'a', |
113 |
|
|
namespace_uri => undef, |
114 |
|
|
next_sibling => undef, |
115 |
wakaba |
1.1 |
node_name => 'a', |
116 |
wakaba |
1.7 |
node_type => 2, |
117 |
wakaba |
1.1 |
name => 'a', |
118 |
|
|
node_value => 'b', |
119 |
wakaba |
1.2 |
owner_document => $doc, |
120 |
|
|
parent_node => undef, |
121 |
|
|
prefix => undef, |
122 |
|
|
previous_sibling => undef, |
123 |
wakaba |
1.1 |
value => 'b', |
124 |
|
|
attributes => undef, |
125 |
|
|
}, |
126 |
wakaba |
1.4 |
attr_get_bool => { |
127 |
wakaba |
1.6 |
has_attributes => 0, |
128 |
|
|
has_child_nodes => 1, |
129 |
wakaba |
1.10 |
manakai_read_only => 0, |
130 |
wakaba |
1.4 |
specified => 1, |
131 |
|
|
}, |
132 |
wakaba |
1.1 |
}, |
133 |
|
|
attr_ns_default => { |
134 |
wakaba |
1.4 |
node => sub { return $doc->create_attribute_ns (undef, 'a') }, |
135 |
wakaba |
1.1 |
attr_get => { |
136 |
wakaba |
1.4 |
base_uri => undef, |
137 |
wakaba |
1.6 |
manakai_expanded_uri => 'a', |
138 |
wakaba |
1.2 |
local_name => 'a', |
139 |
|
|
manakai_local_name => 'a', |
140 |
|
|
namespace_uri => undef, |
141 |
|
|
next_sibling => undef, |
142 |
wakaba |
1.1 |
node_name => 'a', |
143 |
wakaba |
1.7 |
node_type => 2, |
144 |
wakaba |
1.1 |
name => 'a', |
145 |
wakaba |
1.4 |
node_value => '', |
146 |
wakaba |
1.2 |
owner_document => $doc, |
147 |
|
|
parent_node => undef, |
148 |
|
|
prefix => undef, |
149 |
wakaba |
1.4 |
value => '', |
150 |
wakaba |
1.1 |
attributes => undef, |
151 |
wakaba |
1.2 |
previous_sibling => undef, |
152 |
wakaba |
1.1 |
}, |
153 |
wakaba |
1.6 |
attr_get_bool => { |
154 |
|
|
has_attributes => 0, |
155 |
|
|
has_child_nodes => 0, |
156 |
wakaba |
1.10 |
manakai_read_only => 0, |
157 |
wakaba |
1.6 |
specified => 1, |
158 |
|
|
}, |
159 |
wakaba |
1.1 |
}, |
160 |
|
|
attr_ns_prefixed => { |
161 |
wakaba |
1.4 |
node => sub { return $doc->create_attribute_ns ('http://test/', 'a:b') }, |
162 |
wakaba |
1.1 |
attr_get => { |
163 |
wakaba |
1.4 |
base_uri => undef, |
164 |
wakaba |
1.6 |
manakai_expanded_uri => 'http://test/b', |
165 |
wakaba |
1.2 |
local_name => 'b', |
166 |
|
|
manakai_local_name => 'b', |
167 |
|
|
namespace_uri => 'http://test/', |
168 |
|
|
next_sibling => undef, |
169 |
wakaba |
1.1 |
node_name => 'a:b', |
170 |
wakaba |
1.7 |
node_type => 2, |
171 |
wakaba |
1.1 |
name => 'a:b', |
172 |
wakaba |
1.4 |
node_value => '', |
173 |
wakaba |
1.2 |
owner_document => $doc, |
174 |
|
|
parent_node => undef, |
175 |
|
|
prefix => 'a', |
176 |
wakaba |
1.4 |
value => '', |
177 |
wakaba |
1.1 |
attributes => undef, |
178 |
wakaba |
1.2 |
previous_sibling => undef, |
179 |
wakaba |
1.1 |
}, |
180 |
wakaba |
1.6 |
attr_get_bool => { |
181 |
|
|
has_attributes => 0, |
182 |
|
|
has_child_nodes => 0, |
183 |
wakaba |
1.10 |
manakai_read_only => 0, |
184 |
wakaba |
1.6 |
specified => 1, |
185 |
|
|
}, |
186 |
wakaba |
1.1 |
}, |
187 |
wakaba |
1.8 |
attr_ns_prefixed_array => { |
188 |
|
|
node => sub { $doc->create_attribute_ns ('http://test/', ['a', 'b']) }, |
189 |
|
|
attr_get => { |
190 |
|
|
base_uri => undef, |
191 |
|
|
manakai_expanded_uri => 'http://test/b', |
192 |
|
|
local_name => 'b', |
193 |
|
|
manakai_local_name => 'b', |
194 |
|
|
namespace_uri => 'http://test/', |
195 |
|
|
next_sibling => undef, |
196 |
|
|
node_name => 'a:b', |
197 |
|
|
node_type => 2, |
198 |
|
|
name => 'a:b', |
199 |
|
|
node_value => '', |
200 |
|
|
owner_document => $doc, |
201 |
|
|
parent_node => undef, |
202 |
|
|
prefix => 'a', |
203 |
|
|
value => '', |
204 |
|
|
attributes => undef, |
205 |
|
|
previous_sibling => undef, |
206 |
|
|
}, |
207 |
|
|
attr_get_bool => { |
208 |
|
|
has_attributes => 0, |
209 |
|
|
has_child_nodes => 0, |
210 |
wakaba |
1.10 |
manakai_read_only => 0, |
211 |
wakaba |
1.8 |
specified => 1, |
212 |
|
|
}, |
213 |
|
|
}, |
214 |
wakaba |
1.1 |
cdatasection => { |
215 |
|
|
node => sub { return $doc->create_cdata_section ('cdatadata') }, |
216 |
|
|
attr_get => { |
217 |
wakaba |
1.4 |
base_uri => undef, |
218 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
219 |
wakaba |
1.2 |
first_child => undef, |
220 |
|
|
last_child => undef, |
221 |
|
|
local_name => undef, |
222 |
|
|
manakai_local_name => undef, |
223 |
|
|
namespace_uri => undef, |
224 |
|
|
next_sibling => undef, |
225 |
wakaba |
1.1 |
node_name => '#cdata-section', |
226 |
wakaba |
1.7 |
node_type => 4, |
227 |
wakaba |
1.1 |
node_value => 'cdatadata', |
228 |
wakaba |
1.2 |
owner_document => $doc, |
229 |
|
|
parent_node => undef, |
230 |
|
|
prefix => undef, |
231 |
wakaba |
1.1 |
data => 'cdatadata', |
232 |
|
|
attributes => undef, |
233 |
wakaba |
1.2 |
previous_sibling => undef, |
234 |
wakaba |
1.1 |
}, |
235 |
wakaba |
1.6 |
attr_get_bool => { |
236 |
|
|
has_attributes => 0, |
237 |
|
|
has_child_nodes => 0, |
238 |
wakaba |
1.9 |
is_element_content_whitespace => 0, |
239 |
wakaba |
1.10 |
manakai_read_only => 0, |
240 |
wakaba |
1.6 |
}, |
241 |
wakaba |
1.1 |
}, |
242 |
|
|
cdatasectionmde => { |
243 |
|
|
node => sub { return $doc->create_cdata_section ('cdata]]>data') }, |
244 |
|
|
attr_get => { |
245 |
wakaba |
1.4 |
base_uri => undef, |
246 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
247 |
wakaba |
1.2 |
first_child => undef, |
248 |
|
|
last_child => undef, |
249 |
|
|
local_name => undef, |
250 |
|
|
manakai_local_name => undef, |
251 |
|
|
namespace_uri => undef, |
252 |
|
|
next_sibling => undef, |
253 |
wakaba |
1.1 |
node_name => '#cdata-section', |
254 |
wakaba |
1.7 |
node_type => 4, |
255 |
wakaba |
1.1 |
node_value => 'cdata]]>data', |
256 |
wakaba |
1.2 |
owner_document => $doc, |
257 |
|
|
parent_node => undef, |
258 |
|
|
prefix => undef, |
259 |
wakaba |
1.1 |
data => 'cdata]]>data', |
260 |
|
|
attributes => undef, |
261 |
wakaba |
1.2 |
previous_sibling => undef, |
262 |
wakaba |
1.1 |
}, |
263 |
wakaba |
1.6 |
attr_get_bool => { |
264 |
|
|
has_attributes => 0, |
265 |
|
|
has_child_nodes => 0, |
266 |
wakaba |
1.9 |
is_element_content_whitespace => 0, |
267 |
wakaba |
1.10 |
manakai_read_only => 0, |
268 |
wakaba |
1.6 |
}, |
269 |
wakaba |
1.1 |
}, |
270 |
|
|
comment => { |
271 |
|
|
node => sub { return $doc->create_comment ('commentdata') }, |
272 |
|
|
attr_get => { |
273 |
wakaba |
1.4 |
base_uri => undef, |
274 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
275 |
wakaba |
1.2 |
first_child => undef, |
276 |
|
|
last_child => undef, |
277 |
|
|
local_name => undef, |
278 |
|
|
manakai_local_name => undef, |
279 |
|
|
namespace_uri => undef, |
280 |
|
|
next_sibling => undef, |
281 |
wakaba |
1.1 |
node_name => '#comment', |
282 |
wakaba |
1.7 |
node_type => 8, |
283 |
wakaba |
1.1 |
node_value => 'commentdata', |
284 |
wakaba |
1.2 |
owner_document => $doc, |
285 |
|
|
parent_node => undef, |
286 |
|
|
prefix => undef, |
287 |
wakaba |
1.1 |
data => 'commentdata', |
288 |
|
|
attributes => undef, |
289 |
wakaba |
1.2 |
previous_sibling => undef, |
290 |
wakaba |
1.6 |
}, |
291 |
|
|
attr_get_bool => { |
292 |
|
|
has_attributes => 0, |
293 |
|
|
has_child_nodes => 0, |
294 |
wakaba |
1.10 |
manakai_read_only => 0, |
295 |
wakaba |
1.1 |
}, |
296 |
|
|
}, |
297 |
|
|
commentcom1 => { |
298 |
|
|
node => sub { return $doc->create_comment ('comment--data') }, |
299 |
|
|
attr_get => { |
300 |
wakaba |
1.4 |
base_uri => undef, |
301 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
302 |
wakaba |
1.2 |
first_child => undef, |
303 |
|
|
last_child => undef, |
304 |
|
|
local_name => undef, |
305 |
|
|
manakai_local_name => undef, |
306 |
|
|
namespace_uri => undef, |
307 |
|
|
next_sibling => undef, |
308 |
wakaba |
1.1 |
node_name => '#comment', |
309 |
wakaba |
1.7 |
node_type => 8, |
310 |
wakaba |
1.1 |
node_value => 'comment--data', |
311 |
wakaba |
1.2 |
owner_document => $doc, |
312 |
|
|
parent_node => undef, |
313 |
|
|
prefix => undef, |
314 |
wakaba |
1.1 |
data => 'comment--data', |
315 |
|
|
attributes => undef, |
316 |
wakaba |
1.2 |
previous_sibling => undef, |
317 |
wakaba |
1.1 |
}, |
318 |
wakaba |
1.6 |
attr_get_bool => { |
319 |
|
|
has_attributes => 0, |
320 |
|
|
has_child_nodes => 0, |
321 |
wakaba |
1.10 |
manakai_read_only => 0, |
322 |
wakaba |
1.6 |
}, |
323 |
wakaba |
1.1 |
}, |
324 |
|
|
commentcom2 => { |
325 |
|
|
node => sub { return $doc->create_comment ('commentdata-') }, |
326 |
|
|
attr_get => { |
327 |
wakaba |
1.4 |
base_uri => undef, |
328 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
329 |
wakaba |
1.2 |
first_child => undef, |
330 |
|
|
last_child => undef, |
331 |
|
|
local_name => undef, |
332 |
|
|
manakai_local_name => undef, |
333 |
|
|
namespace_uri => undef, |
334 |
|
|
next_sibling => undef, |
335 |
wakaba |
1.1 |
node_name => '#comment', |
336 |
wakaba |
1.7 |
node_type => 8, |
337 |
wakaba |
1.1 |
node_value => 'commentdata-', |
338 |
wakaba |
1.2 |
owner_document => $doc, |
339 |
|
|
parent_node => undef, |
340 |
|
|
prefix => undef, |
341 |
wakaba |
1.1 |
data => 'commentdata-', |
342 |
|
|
attributes => undef, |
343 |
wakaba |
1.2 |
previous_sibling => undef, |
344 |
wakaba |
1.1 |
}, |
345 |
wakaba |
1.6 |
attr_get_bool => { |
346 |
|
|
has_attributes => 0, |
347 |
|
|
has_child_nodes => 0, |
348 |
wakaba |
1.10 |
manakai_read_only => 0, |
349 |
wakaba |
1.6 |
}, |
350 |
wakaba |
1.1 |
}, |
351 |
|
|
document => { |
352 |
|
|
node => sub { return $doc }, |
353 |
|
|
attr_get => { |
354 |
|
|
attributes => undef, |
355 |
wakaba |
1.4 |
base_uri => undef, |
356 |
|
|
document_uri => undef, |
357 |
|
|
manakai_entity_base_uri => undef, |
358 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
359 |
wakaba |
1.2 |
first_child => undef, |
360 |
|
|
implementation => $dom, |
361 |
|
|
last_child => undef, |
362 |
wakaba |
1.1 |
local_name => undef, |
363 |
wakaba |
1.2 |
manakai_local_name => undef, |
364 |
wakaba |
1.1 |
namespace_uri => undef, |
365 |
wakaba |
1.2 |
next_sibling => undef, |
366 |
wakaba |
1.1 |
node_name => '#document', |
367 |
wakaba |
1.7 |
node_type => 9, |
368 |
wakaba |
1.1 |
node_value => undef, |
369 |
wakaba |
1.2 |
owner_document => undef, |
370 |
wakaba |
1.1 |
parent_node => undef, |
371 |
|
|
prefix => undef, |
372 |
wakaba |
1.2 |
previous_sibling => undef, |
373 |
wakaba |
1.4 |
xml_encoding => undef, |
374 |
|
|
xml_version => '1.0', |
375 |
|
|
}, |
376 |
|
|
attr_get_bool => { |
377 |
|
|
all_declarations_processed => 0, |
378 |
wakaba |
1.6 |
has_attributes => 0, |
379 |
|
|
has_child_nodes => 0, |
380 |
wakaba |
1.4 |
manakai_is_html => 0, |
381 |
wakaba |
1.10 |
manakai_read_only => 0, |
382 |
wakaba |
1.4 |
strict_error_checking => 1, |
383 |
|
|
xml_standalone => 0, |
384 |
wakaba |
1.1 |
}, |
385 |
|
|
}, |
386 |
|
|
document_fragment => { |
387 |
|
|
node => sub { return $doc->create_document_fragment }, |
388 |
|
|
attr_get => { |
389 |
|
|
attributes => undef, |
390 |
wakaba |
1.4 |
base_uri => undef, |
391 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
392 |
wakaba |
1.2 |
first_child => undef, |
393 |
|
|
last_child => undef, |
394 |
|
|
local_name => undef, |
395 |
|
|
manakai_local_name => undef, |
396 |
|
|
namespace_uri => undef, |
397 |
|
|
next_sibling => undef, |
398 |
wakaba |
1.1 |
node_name => '#document-fragment', |
399 |
wakaba |
1.7 |
node_type => 11, |
400 |
wakaba |
1.1 |
node_value => undef, |
401 |
wakaba |
1.2 |
owner_document => $doc, |
402 |
|
|
parent_node => undef, |
403 |
|
|
prefix => undef, |
404 |
|
|
previous_sibling => undef, |
405 |
wakaba |
1.1 |
}, |
406 |
wakaba |
1.6 |
attr_get_bool => { |
407 |
|
|
has_attributes => 0, |
408 |
|
|
has_child_nodes => 0, |
409 |
wakaba |
1.10 |
manakai_read_only => 0, |
410 |
wakaba |
1.6 |
}, |
411 |
wakaba |
1.1 |
}, |
412 |
|
|
document_type => { |
413 |
|
|
node => sub { return $doc->implementation->create_document_type ('n') }, |
414 |
|
|
attr_get => { |
415 |
|
|
attributes => undef, |
416 |
wakaba |
1.4 |
base_uri => undef, |
417 |
|
|
declaration_base_uri => undef, |
418 |
|
|
manakai_declaration_base_uri => undef, |
419 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
420 |
wakaba |
1.2 |
first_child => undef, |
421 |
|
|
implementation => $dom, |
422 |
|
|
last_child => undef, |
423 |
|
|
local_name => undef, |
424 |
|
|
manakai_local_name => undef, |
425 |
|
|
namespace_uri => undef, |
426 |
|
|
next_sibling => undef, |
427 |
wakaba |
1.1 |
node_name => 'n', |
428 |
wakaba |
1.7 |
node_type => 10, |
429 |
wakaba |
1.1 |
node_value => undef, |
430 |
wakaba |
1.2 |
owner_document => undef, |
431 |
|
|
parent_node => undef, |
432 |
|
|
prefix => undef, |
433 |
|
|
previous_sibling => undef, |
434 |
wakaba |
1.4 |
public_id => undef, |
435 |
|
|
system_id => undef, |
436 |
wakaba |
1.1 |
}, |
437 |
wakaba |
1.6 |
attr_get_bool => { |
438 |
|
|
has_attributes => 0, |
439 |
|
|
has_child_nodes => 0, |
440 |
wakaba |
1.10 |
manakai_read_only => 1, |
441 |
wakaba |
1.6 |
}, |
442 |
wakaba |
1.1 |
}, |
443 |
|
|
document_type_definition => { |
444 |
|
|
node => sub { return $doc->create_document_type_definition ('n') }, |
445 |
|
|
attr_get => { |
446 |
|
|
attributes => undef, |
447 |
wakaba |
1.4 |
base_uri => undef, |
448 |
|
|
declaration_base_uri => undef, |
449 |
|
|
manakai_declaration_base_uri => undef, |
450 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
451 |
wakaba |
1.2 |
first_child => undef, |
452 |
|
|
implementation => $dom, |
453 |
|
|
last_child => undef, |
454 |
|
|
local_name => undef, |
455 |
|
|
manakai_local_name => undef, |
456 |
|
|
namespace_uri => undef, |
457 |
|
|
next_sibling => undef, |
458 |
wakaba |
1.1 |
node_name => 'n', |
459 |
wakaba |
1.7 |
node_type => 10, |
460 |
wakaba |
1.1 |
node_value => undef, |
461 |
wakaba |
1.2 |
owner_document => $doc, |
462 |
|
|
parent_node => undef, |
463 |
|
|
prefix => undef, |
464 |
|
|
previous_sibling => undef, |
465 |
wakaba |
1.4 |
public_id => undef, |
466 |
|
|
system_id => undef, |
467 |
wakaba |
1.1 |
}, |
468 |
wakaba |
1.6 |
attr_get_bool => { |
469 |
|
|
has_attributes => 0, |
470 |
|
|
has_child_nodes => 0, |
471 |
wakaba |
1.10 |
manakai_read_only => 0, |
472 |
wakaba |
1.6 |
}, |
473 |
wakaba |
1.1 |
}, |
474 |
|
|
element => { |
475 |
|
|
node => sub { return $doc->create_element ('e') }, |
476 |
|
|
attr_get => { |
477 |
|
|
## TODO: attributes => |
478 |
wakaba |
1.4 |
base_uri => undef, |
479 |
|
|
manakai_base_uri => undef, |
480 |
wakaba |
1.6 |
manakai_expanded_uri => 'e', |
481 |
wakaba |
1.2 |
first_child => undef, |
482 |
|
|
last_child => undef, |
483 |
|
|
local_name => 'e', |
484 |
|
|
manakai_local_name => 'e', |
485 |
|
|
namespace_uri => undef, |
486 |
|
|
next_sibling => undef, |
487 |
wakaba |
1.1 |
node_name => 'e', |
488 |
wakaba |
1.7 |
node_type => 1, |
489 |
wakaba |
1.1 |
node_value => undef, |
490 |
wakaba |
1.2 |
owner_document => $doc, |
491 |
|
|
parent_node => undef, |
492 |
|
|
prefix => undef, |
493 |
|
|
previous_sibling => undef, |
494 |
wakaba |
1.1 |
}, |
495 |
wakaba |
1.6 |
attr_get_bool => { |
496 |
|
|
has_attributes => 0, |
497 |
|
|
has_child_nodes => 0, |
498 |
wakaba |
1.10 |
manakai_read_only => 0, |
499 |
wakaba |
1.6 |
}, |
500 |
wakaba |
1.1 |
}, |
501 |
|
|
element_ns_default => { |
502 |
|
|
node => sub { return $doc->create_element_ns ('http://test/', 'f') }, |
503 |
|
|
attr_get => { |
504 |
|
|
## TODO: attributes => |
505 |
wakaba |
1.4 |
base_uri => undef, |
506 |
|
|
manakai_base_uri => undef, |
507 |
wakaba |
1.6 |
manakai_expanded_uri => 'http://test/f', |
508 |
wakaba |
1.2 |
first_child => undef, |
509 |
|
|
last_child => undef, |
510 |
|
|
local_name => 'f', |
511 |
|
|
manakai_local_name => 'f', |
512 |
|
|
namespace_uri => 'http://test/', |
513 |
|
|
next_sibling => undef, |
514 |
wakaba |
1.1 |
node_name => 'f', |
515 |
wakaba |
1.7 |
node_type => 1, |
516 |
wakaba |
1.1 |
node_value => undef, |
517 |
wakaba |
1.2 |
owner_document => $doc, |
518 |
|
|
parent_node => undef, |
519 |
|
|
prefix => undef, |
520 |
|
|
previous_sibling => undef, |
521 |
wakaba |
1.1 |
}, |
522 |
wakaba |
1.6 |
attr_get_bool => { |
523 |
|
|
has_attributes => 0, |
524 |
|
|
has_child_nodes => 0, |
525 |
wakaba |
1.10 |
manakai_read_only => 0, |
526 |
wakaba |
1.6 |
}, |
527 |
wakaba |
1.1 |
}, |
528 |
|
|
element_ns_prefiexed => { |
529 |
|
|
node => sub { return $doc->create_element_ns ('http://test/', 'e:f') }, |
530 |
|
|
attr_get => { |
531 |
|
|
## TODO: attributes => |
532 |
wakaba |
1.4 |
base_uri => undef, |
533 |
|
|
manakai_base_uri => undef, |
534 |
wakaba |
1.6 |
manakai_expanded_uri => 'http://test/f', |
535 |
wakaba |
1.2 |
first_child => undef, |
536 |
|
|
last_child => undef, |
537 |
|
|
local_name => 'f', |
538 |
|
|
manakai_local_name => 'f', |
539 |
|
|
namespace_uri => 'http://test/', |
540 |
|
|
next_sibling => undef, |
541 |
wakaba |
1.1 |
node_name => 'e:f', |
542 |
wakaba |
1.7 |
node_type => 1, |
543 |
wakaba |
1.1 |
node_value => undef, |
544 |
wakaba |
1.2 |
owner_document => $doc, |
545 |
|
|
parent_node => undef, |
546 |
|
|
prefix => 'e', |
547 |
|
|
previous_sibling => undef, |
548 |
wakaba |
1.1 |
}, |
549 |
wakaba |
1.6 |
attr_get_bool => { |
550 |
|
|
has_attributes => 0, |
551 |
|
|
has_child_nodes => 0, |
552 |
wakaba |
1.10 |
manakai_read_only => 0, |
553 |
wakaba |
1.6 |
}, |
554 |
wakaba |
1.1 |
}, |
555 |
|
|
entity => { |
556 |
|
|
node => sub { return $doc->create_general_entity ('e') }, |
557 |
|
|
attr_get => { |
558 |
|
|
attributes => undef, |
559 |
wakaba |
1.4 |
base_uri => undef, |
560 |
|
|
manakai_declaration_base_uri => undef, |
561 |
|
|
manakai_entity_base_uri => undef, |
562 |
|
|
manakai_entity_uri => undef, |
563 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
564 |
wakaba |
1.2 |
first_child => undef, |
565 |
|
|
last_child => undef, |
566 |
|
|
next_sibling => undef, |
567 |
wakaba |
1.1 |
node_name => 'e', |
568 |
wakaba |
1.7 |
node_type => 6, |
569 |
wakaba |
1.1 |
node_value => undef, |
570 |
wakaba |
1.5 |
notation_name => undef, |
571 |
wakaba |
1.2 |
owner_document => $doc, |
572 |
|
|
parent_node => undef, |
573 |
|
|
previous_sibling => undef, |
574 |
wakaba |
1.4 |
public_id => undef, |
575 |
|
|
system_id => undef, |
576 |
wakaba |
1.1 |
}, |
577 |
wakaba |
1.6 |
attr_get_bool => { |
578 |
|
|
has_attributes => 0, |
579 |
|
|
has_child_nodes => 0, |
580 |
wakaba |
1.10 |
manakai_read_only => 0, |
581 |
wakaba |
1.6 |
}, |
582 |
wakaba |
1.1 |
}, |
583 |
|
|
entity_reference => { |
584 |
|
|
node => sub { return $doc->create_entity_reference ('e') }, |
585 |
|
|
attr_get => { |
586 |
|
|
attributes => undef, |
587 |
wakaba |
1.4 |
base_uri => undef, |
588 |
|
|
manakai_entity_base_uri => undef, |
589 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
590 |
wakaba |
1.2 |
first_child => undef, |
591 |
|
|
last_child => undef, |
592 |
|
|
local_name => undef, |
593 |
|
|
manakai_local_name => undef, |
594 |
|
|
namespace_uri => undef, |
595 |
|
|
next_sibling => undef, |
596 |
wakaba |
1.1 |
node_name => 'e', |
597 |
wakaba |
1.7 |
node_type => 5, |
598 |
wakaba |
1.1 |
node_value => undef, |
599 |
wakaba |
1.2 |
owner_document => $doc, |
600 |
|
|
parent_node => undef, |
601 |
|
|
prefix => undef, |
602 |
|
|
previous_sibling => undef, |
603 |
wakaba |
1.1 |
}, |
604 |
wakaba |
1.4 |
attr_get_bool => { |
605 |
|
|
manakai_expanded => 0, |
606 |
|
|
manakai_external => 0, |
607 |
wakaba |
1.6 |
has_attributes => 0, |
608 |
|
|
has_child_nodes => 0, |
609 |
wakaba |
1.10 |
manakai_read_only => 1, |
610 |
wakaba |
1.4 |
}, |
611 |
wakaba |
1.1 |
}, |
612 |
|
|
notation => { |
613 |
|
|
node => sub { return $doc->create_notation ('e') }, |
614 |
|
|
attr_get => { |
615 |
|
|
attributes => undef, |
616 |
wakaba |
1.4 |
base_uri => undef, |
617 |
|
|
manakai_declaration_base_uri => undef, |
618 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
619 |
wakaba |
1.2 |
first_child => undef, |
620 |
|
|
last_child => undef, |
621 |
|
|
local_name => undef, |
622 |
|
|
manakai_local_name => undef, |
623 |
|
|
namespace_uri => undef, |
624 |
|
|
next_sibling => undef, |
625 |
wakaba |
1.1 |
node_name => 'e', |
626 |
wakaba |
1.7 |
node_type => 12, |
627 |
wakaba |
1.1 |
node_value => undef, |
628 |
wakaba |
1.2 |
owner_document => $doc, |
629 |
|
|
parent_node => undef, |
630 |
|
|
prefix => undef, |
631 |
|
|
previous_sibling => undef, |
632 |
wakaba |
1.4 |
public_id => undef, |
633 |
|
|
system_id => undef, |
634 |
wakaba |
1.1 |
}, |
635 |
wakaba |
1.6 |
attr_get_bool => { |
636 |
|
|
has_attributes => 0, |
637 |
|
|
has_child_nodes => 0, |
638 |
wakaba |
1.10 |
manakai_read_only => 0, |
639 |
wakaba |
1.6 |
}, |
640 |
wakaba |
1.1 |
}, |
641 |
|
|
processing_instruction => { |
642 |
|
|
node => sub { return $doc->create_processing_instruction ('t', 'd') }, |
643 |
|
|
attr_get => { |
644 |
|
|
attributes => undef, |
645 |
wakaba |
1.4 |
base_uri => undef, |
646 |
|
|
manakai_base_uri => undef, |
647 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
648 |
wakaba |
1.2 |
first_child => undef, |
649 |
|
|
last_child => undef, |
650 |
|
|
local_name => undef, |
651 |
|
|
manakai_local_name => undef, |
652 |
|
|
namespace_uri => undef, |
653 |
|
|
next_sibling => undef, |
654 |
wakaba |
1.1 |
node_name => 't', |
655 |
wakaba |
1.7 |
node_type => 7, |
656 |
wakaba |
1.1 |
node_value => 'd', |
657 |
wakaba |
1.2 |
owner_document => $doc, |
658 |
|
|
parent_node => undef, |
659 |
|
|
prefix => undef, |
660 |
|
|
previous_sibling => undef, |
661 |
wakaba |
1.1 |
}, |
662 |
wakaba |
1.6 |
attr_get_bool => { |
663 |
|
|
has_attributes => 0, |
664 |
|
|
has_child_nodes => 0, |
665 |
wakaba |
1.10 |
manakai_read_only => 0, |
666 |
wakaba |
1.6 |
}, |
667 |
wakaba |
1.1 |
}, |
668 |
|
|
text => { |
669 |
|
|
node => sub { return $doc->create_text_node ('textdata') }, |
670 |
|
|
attr_get => { |
671 |
|
|
attributes => undef, |
672 |
wakaba |
1.4 |
base_uri => undef, |
673 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
674 |
wakaba |
1.2 |
first_child => undef, |
675 |
|
|
last_child => undef, |
676 |
|
|
local_name => undef, |
677 |
|
|
manakai_local_name => undef, |
678 |
|
|
namespace_uri => undef, |
679 |
|
|
next_sibling => undef, |
680 |
wakaba |
1.1 |
node_name => '#text', |
681 |
wakaba |
1.7 |
node_type => 3, |
682 |
wakaba |
1.1 |
node_value => 'textdata', |
683 |
wakaba |
1.2 |
owner_document => $doc, |
684 |
|
|
parent_node => undef, |
685 |
|
|
prefix => undef, |
686 |
|
|
previous_sibling => undef, |
687 |
wakaba |
1.1 |
}, |
688 |
wakaba |
1.6 |
attr_get_bool => { |
689 |
|
|
has_attributes => 0, |
690 |
|
|
has_child_nodes => 0, |
691 |
wakaba |
1.9 |
is_element_content_whitespace => 0, |
692 |
wakaba |
1.10 |
manakai_read_only => 0, |
693 |
wakaba |
1.6 |
}, |
694 |
wakaba |
1.1 |
}, |
695 |
|
|
element_type_definition => { |
696 |
|
|
node => sub { return $doc->create_element_type_definition ('e') }, |
697 |
|
|
attr_get => { |
698 |
|
|
attributes => undef, |
699 |
wakaba |
1.4 |
base_uri => undef, |
700 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
701 |
wakaba |
1.2 |
first_child => undef, |
702 |
|
|
last_child => undef, |
703 |
|
|
local_name => undef, |
704 |
|
|
manakai_local_name => undef, |
705 |
|
|
namespace_uri => undef, |
706 |
|
|
next_sibling => undef, |
707 |
wakaba |
1.1 |
node_name => 'e', |
708 |
wakaba |
1.7 |
node_type => 81001, |
709 |
wakaba |
1.1 |
node_value => undef, |
710 |
wakaba |
1.2 |
owner_document => $doc, |
711 |
|
|
parent_node => undef, |
712 |
|
|
prefix => undef, |
713 |
|
|
previous_sibling => undef, |
714 |
wakaba |
1.1 |
}, |
715 |
wakaba |
1.6 |
attr_get_bool => { |
716 |
|
|
has_attributes => 0, |
717 |
|
|
has_child_nodes => 0, |
718 |
wakaba |
1.10 |
manakai_read_only => 0, |
719 |
wakaba |
1.6 |
}, |
720 |
wakaba |
1.1 |
}, |
721 |
|
|
attribute_definition => { |
722 |
|
|
node => sub { return $doc->create_attribute_definition ('e') }, |
723 |
|
|
attr_get => { |
724 |
|
|
attributes => undef, |
725 |
wakaba |
1.4 |
base_uri => undef, |
726 |
|
|
declared_type => 0, |
727 |
|
|
default_type => 0, |
728 |
wakaba |
1.6 |
manakai_expanded_uri => undef, |
729 |
wakaba |
1.2 |
first_child => undef, |
730 |
|
|
last_child => undef, |
731 |
|
|
local_name => undef, |
732 |
|
|
manakai_local_name => undef, |
733 |
|
|
namespace_uri => undef, |
734 |
|
|
next_sibling => undef, |
735 |
wakaba |
1.1 |
node_name => 'e', |
736 |
wakaba |
1.7 |
node_type => 81002, |
737 |
wakaba |
1.1 |
node_value => undef, |
738 |
wakaba |
1.2 |
owner_document => $doc, |
739 |
|
|
parent_node => undef, |
740 |
|
|
prefix => undef, |
741 |
|
|
previous_sibling => undef, |
742 |
wakaba |
1.1 |
}, |
743 |
wakaba |
1.6 |
attr_get_bool => { |
744 |
|
|
has_attributes => 0, |
745 |
|
|
has_child_nodes => 0, |
746 |
wakaba |
1.10 |
manakai_read_only => 0, |
747 |
wakaba |
1.6 |
}, |
748 |
wakaba |
1.1 |
}, |
749 |
|
|
}; |
750 |
|
|
|
751 |
|
|
for my $test_id (sort {$a cmp $b} keys %$tests) { |
752 |
|
|
my $test_def = $tests->{$test_id}; |
753 |
|
|
my $node = $test_def->{node}->(); |
754 |
|
|
|
755 |
|
|
for (@$constants) { |
756 |
|
|
my $const_name = $_->[0]; |
757 |
|
|
ok $node->can ($const_name) ? 1 : 0, 1, "$test_id->can ($const_name)"; |
758 |
|
|
ok $node->$const_name, $_->[1], "$test_id.$const_name"; |
759 |
|
|
} |
760 |
|
|
|
761 |
|
|
for my $attr_name (sort {$a cmp $b} keys %{$test_def->{attr_get}}) { |
762 |
|
|
my $expected = $test_def->{attr_get}->{$attr_name}; |
763 |
|
|
ok $node->can ($attr_name) ? 1 : 0, 1, "$test_id->can ($attr_name)"; |
764 |
|
|
my $actual = $node->$attr_name; |
765 |
|
|
ok $actual, $expected, "$test_id.$attr_name.get"; |
766 |
|
|
} |
767 |
wakaba |
1.4 |
|
768 |
|
|
for my $attr_name (sort {$a cmp $b} keys %{$test_def->{attr_get_bool} or {}}) { |
769 |
|
|
my $expected = $test_def->{attr_get_bool}->{$attr_name} ? 1 : 0; |
770 |
|
|
ok $node->can ($attr_name) ? 1 : 0, 1, "$test_id->can ($attr_name)"; |
771 |
|
|
my $actual = $node->$attr_name ? 1 : 0; |
772 |
|
|
ok $actual, $expected, "$test_id.$attr_name.get"; |
773 |
|
|
} |
774 |
wakaba |
1.1 |
} |
775 |
|
|
|
776 |
wakaba |
1.2 |
## Child node accessors' tests |
777 |
|
|
for my $parent (create_parent_nodes ()) { |
778 |
|
|
my $node1; |
779 |
|
|
my $node2; |
780 |
|
|
my $node3; |
781 |
|
|
if ($parent->node_type == $parent->DOCUMENT_TYPE_NODE) { |
782 |
|
|
$node1 = $doc->create_processing_instruction ('pi1', 'data1'); |
783 |
|
|
$node2 = $doc->create_processing_instruction ('pi2', 'data2'); |
784 |
|
|
$node3 = $doc->create_processing_instruction ('pi3', 'data3'); |
785 |
|
|
} elsif ($parent->node_type == $parent->DOCUMENT_NODE) { |
786 |
|
|
$node1 = $doc->create_comment ('comment1'); |
787 |
|
|
$node2 = $doc->create_comment ('comment2'); |
788 |
|
|
$node3 = $doc->create_comment ('comment3'); |
789 |
|
|
} else { |
790 |
|
|
$node1 = $doc->create_text_node ('text1'); |
791 |
|
|
$node2 = $doc->create_text_node ('text2'); |
792 |
|
|
$node3 = $doc->create_text_node ('text3'); |
793 |
|
|
} |
794 |
|
|
|
795 |
|
|
$parent->append_child ($node1); |
796 |
|
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [1]"; |
797 |
|
|
ok $parent->last_child, $node1, $parent->node_name."->last_child [1]"; |
798 |
|
|
ok $node1->next_sibling, undef, $parent->node_name."->next_sibling [1]"; |
799 |
|
|
ok $node1->previous_sibling, undef, $parent->node_name."->previous_sibling [1]"; |
800 |
|
|
|
801 |
|
|
$parent->append_child ($node2); |
802 |
|
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [2]"; |
803 |
|
|
ok $parent->last_child, $node2, $parent->node_name."->last_child [2]"; |
804 |
|
|
ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [2]"; |
805 |
|
|
ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [2]"; |
806 |
|
|
ok $node2->next_sibling, undef, $parent->node_name."2->next_sibling [2]"; |
807 |
|
|
ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [2]"; |
808 |
|
|
|
809 |
|
|
$parent->append_child ($node3); |
810 |
|
|
ok $parent->first_child, $node1, $parent->node_name."->first_child [3]"; |
811 |
|
|
ok $parent->last_child, $node3, $parent->node_name."->last_child [3]"; |
812 |
|
|
ok $node1->next_sibling, $node2, $parent->node_name."1->next_sibling [3]"; |
813 |
|
|
ok $node1->previous_sibling, undef, $parent->node_name."1->previous_sibling [3]"; |
814 |
|
|
ok $node2->next_sibling, $node3, $parent->node_name."2->next_sibling [3]"; |
815 |
|
|
ok $node2->previous_sibling, $node1, $parent->node_name."2->previous_sibling [3]"; |
816 |
|
|
ok $node3->next_sibling, undef, $parent->node_name."3->next_sibling [3]"; |
817 |
|
|
ok $node3->previous_sibling, $node2, $parent->node_name."3->previous_sibling [3]"; |
818 |
|
|
} |
819 |
|
|
|
820 |
wakaba |
1.3 |
## |prefix| setter |
821 |
|
|
for my $node (create_nodes ()) { |
822 |
|
|
$node->manakai_set_read_only (0); |
823 |
|
|
|
824 |
|
|
$node->prefix ('non-null'); |
825 |
|
|
if ($node->node_type == $node->ELEMENT_NODE or |
826 |
|
|
$node->node_type == $node->ATTRIBUTE_NODE) { |
827 |
|
|
ok $node->prefix, 'non-null', $node->node_name . '->prefix (non-null)'; |
828 |
|
|
} else { |
829 |
|
|
ok $node->prefix, undef, $node->node_name . '->prefix (non-null)'; |
830 |
|
|
} |
831 |
|
|
|
832 |
|
|
$node->prefix (undef); |
833 |
|
|
if ($node->node_type == $node->ELEMENT_NODE or |
834 |
|
|
$node->node_type == $node->ATTRIBUTE_NODE) { |
835 |
|
|
ok $node->prefix, undef, $node->node_name . '->prefix (null)'; |
836 |
|
|
} else { |
837 |
|
|
ok $node->prefix, undef, $node->node_name . '->prefix (null)'; |
838 |
|
|
} |
839 |
|
|
|
840 |
|
|
$node->manakai_set_read_only (1); |
841 |
|
|
my $err_type; |
842 |
|
|
try { |
843 |
|
|
$node->prefix ('non-null'); |
844 |
|
|
} catch Message::IF::DOMException with { |
845 |
|
|
my $err = shift; |
846 |
|
|
$err_type = $err->type; |
847 |
|
|
}; |
848 |
|
|
if ($node->node_type == $node->ELEMENT_NODE or |
849 |
|
|
$node->node_type == $node->ATTRIBUTE_NODE) { |
850 |
|
|
ok $err_type, 'NO_MODIFICATION_ALLOWED_ERR', |
851 |
|
|
$node->node_name . '->prefix exception (read-only)'; |
852 |
|
|
ok $node->prefix, undef, $node->node_name . '->prefix (read-only)'; |
853 |
|
|
} else { |
854 |
|
|
ok $err_type, undef, $node->node_name . '->prefix exception (read-only)'; |
855 |
|
|
ok $node->prefix, undef, $node->node_name . '->prefix (read-only)'; |
856 |
|
|
} |
857 |
|
|
} |
858 |
|
|
|
859 |
|
|
## |text_content| |
860 |
|
|
{ |
861 |
|
|
my $doc2 = $doc->implementation->create_document; |
862 |
|
|
$doc2->dom_config->set_parameter |
863 |
|
|
('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 1); |
864 |
|
|
for my $node ( |
865 |
|
|
$doc2, |
866 |
|
|
$doc->create_document_type_definition ('dt1'), |
867 |
|
|
$doc->implementation->create_document_type ('doctype1'), |
868 |
|
|
$doc->create_notation ('notation1'), |
869 |
|
|
$doc->create_element_type_definition ('et1'), |
870 |
|
|
) { |
871 |
|
|
ok $node->can ('text_content') ? 1 : 0, 1, |
872 |
|
|
$node->node_name . '->can text_content'; |
873 |
|
|
|
874 |
|
|
ok $node->text_content, undef, $node->node_name . '->text_content'; |
875 |
|
|
|
876 |
|
|
$node->manakai_set_read_only (0); |
877 |
|
|
$node->text_content ('new-text-content'); |
878 |
|
|
ok $node->text_content, undef, $node->node_name . '->text_content set'; |
879 |
|
|
|
880 |
|
|
$node->manakai_set_read_only (1); |
881 |
|
|
$node->text_content ('new-text-content'); |
882 |
|
|
ok $node->text_content, undef, |
883 |
|
|
$node->node_name . '->text_content set (read-only)'; |
884 |
|
|
} |
885 |
|
|
|
886 |
|
|
$doc2->dom_config->set_parameter |
887 |
|
|
('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 0); |
888 |
|
|
for my $node ( |
889 |
|
|
$doc2, |
890 |
|
|
$doc->create_attribute ('attr1'), |
891 |
|
|
$doc->create_attribute_definition ('at1'), |
892 |
|
|
$doc->create_element ('element1'), |
893 |
|
|
$doc->create_general_entity ('entity1'), |
894 |
|
|
$doc->create_entity_reference ('entity-reference1'), |
895 |
|
|
$doc->create_document_fragment, |
896 |
|
|
) { |
897 |
|
|
ok $node->can ('text_content') ? 1 : 0, 1, |
898 |
|
|
$node->node_name . '->can text_content'; |
899 |
|
|
|
900 |
|
|
ok $node->text_content, '', $node->node_name . '->text_content'; |
901 |
|
|
|
902 |
|
|
$node->manakai_set_read_only (0); |
903 |
|
|
$node->text_content ('text1'); |
904 |
|
|
ok $node->text_content, 'text1', $node->node_name . '->text_content set'; |
905 |
|
|
ok 0+@{$node->child_nodes}, 1, |
906 |
|
|
$node->node_name . '->text_content set child_nodes length'; |
907 |
|
|
|
908 |
|
|
$node->text_content (''); |
909 |
|
|
ok $node->text_content, '', $node->node_name . '->text_content set empty'; |
910 |
|
|
ok 0+@{$node->child_nodes}, 0, |
911 |
|
|
$node->node_name . '->text_content set empty child_nodes length'; |
912 |
|
|
|
913 |
|
|
$node->text_content ('text2'); |
914 |
|
|
$node->text_content (''); |
915 |
|
|
ok $node->text_content, '', $node->node_name . '->text_content set empty'; |
916 |
|
|
ok 0+@{$node->child_nodes}, 0, |
917 |
|
|
$node->node_name . '->text_content set empty child_nodes length'; |
918 |
|
|
|
919 |
|
|
$node->text_content ('text3'); |
920 |
|
|
$node->manakai_set_read_only (1); |
921 |
|
|
try { |
922 |
|
|
$node->text_content ('new-text-content'); |
923 |
|
|
ok undef, 'NO_MODIFICATION_ALLOWED_ERR', |
924 |
|
|
$node->node_name . '->text_content set (read-only)'; |
925 |
|
|
} catch Message::IF::DOMException with { |
926 |
|
|
my $err = shift; |
927 |
|
|
ok $err->type, 'NO_MODIFICATION_ALLOWED_ERR', |
928 |
|
|
$node->node_name . '->text_content set (read-only)'; |
929 |
|
|
}; |
930 |
|
|
ok $node->text_content, 'text3', |
931 |
|
|
$node->node_name . '->text_content set (read-only) text_content'; |
932 |
|
|
} |
933 |
|
|
|
934 |
|
|
|
935 |
|
|
for (0..2) { |
936 |
|
|
my $el; |
937 |
|
|
my $ce; |
938 |
|
|
|
939 |
|
|
[ |
940 |
|
|
sub { |
941 |
|
|
$el = $doc->create_element ('nestingElement'); |
942 |
|
|
$ce = $doc->create_element ('el2'); |
943 |
|
|
}, |
944 |
|
|
sub { |
945 |
|
|
$el = $doc->create_element ('elementWithEntityReference'); |
946 |
|
|
$ce = $doc->create_entity_reference ('ent'); |
947 |
|
|
$ce->manakai_set_read_only (0, 1); |
948 |
|
|
}, |
949 |
|
|
sub { |
950 |
|
|
$el = $doc->create_general_entity ('generalEntityWithChild'); |
951 |
|
|
$ce = $doc->create_element ('el'); |
952 |
|
|
$el->manakai_set_read_only (0, 1); |
953 |
|
|
}, |
954 |
|
|
]->[$_]->(); |
955 |
|
|
$el->append_child ($ce); |
956 |
|
|
|
957 |
|
|
ok $el->text_content, '', $el->node_name . '->text_content [1]'; |
958 |
|
|
|
959 |
|
|
$ce->text_content ('gc'); |
960 |
|
|
ok $el->text_content, 'gc', $el->node_name . '->text_content [2]'; |
961 |
|
|
|
962 |
|
|
$el->manakai_append_text ('cc'); |
963 |
|
|
ok $el->text_content, 'gccc', $el->node_name . '->text_content [3]'; |
964 |
|
|
|
965 |
|
|
$el->text_content ('nc'); |
966 |
|
|
ok $el->text_content, 'nc', $el->node_name . '->text_content [4]'; |
967 |
|
|
ok 0+@{$el->child_nodes}, 1, |
968 |
|
|
$el->node_name . '->text_content child_nodes length [4]'; |
969 |
|
|
ok $ce->parent_node, undef, |
970 |
|
|
$el->node_name . '->text_content old_child parent_node [4]'; |
971 |
|
|
} |
972 |
|
|
} |
973 |
|
|
|
974 |
wakaba |
1.4 |
## |manakaiReadOnly| and |manakaiSetReadOnly| |
975 |
|
|
{ |
976 |
|
|
for my $node (create_nodes ()) { |
977 |
|
|
$node->manakai_set_read_only (1, 0); |
978 |
|
|
ok $node->manakai_read_only ? 1 : 0, 1, |
979 |
|
|
$node->node_name . '->manakai_set_read_only (1, 0) [1]'; |
980 |
|
|
|
981 |
|
|
$node->manakai_set_read_only (0, 0); |
982 |
|
|
ok $node->manakai_read_only ? 1 : 0, 0, |
983 |
|
|
$node->node_name . '->manakai_set_read_only (0, 0)'; |
984 |
|
|
|
985 |
|
|
$node->manakai_set_read_only (1, 0); |
986 |
|
|
ok $node->manakai_read_only ? 1 : 0, 1, |
987 |
|
|
$node->node_name . '->manakai_set_read_only (1, 0) [2]'; |
988 |
|
|
} |
989 |
|
|
|
990 |
|
|
{ |
991 |
|
|
my $el = $doc->create_element ('readOnlyElement1'); |
992 |
|
|
my $c1 = $doc->create_element ('c1'); |
993 |
|
|
$el->append_child ($c1); |
994 |
|
|
my $c2 = $doc->create_text_node ('c2'); |
995 |
|
|
$el->append_child ($c2); |
996 |
|
|
my $c3 = $doc->create_element ('c3'); |
997 |
|
|
$el->append_child ($c3); |
998 |
|
|
my $c4 = $doc->create_attribute ('c4'); |
999 |
|
|
$el->set_attribute_node ($c4); |
1000 |
|
|
my $c5 = $doc->create_entity_reference ('c5'); |
1001 |
|
|
$el->append_child ($c5); |
1002 |
|
|
|
1003 |
|
|
$el->manakai_set_read_only (1, 1); |
1004 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1005 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1006 |
|
|
$el->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]'; |
1007 |
|
|
} |
1008 |
|
|
|
1009 |
|
|
$el->manakai_set_read_only (0, 1); |
1010 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1011 |
|
|
ok $_->manakai_read_only ? 1 : 0, 0, |
1012 |
|
|
$el->node_name . '->read_only (1, 0) ' . $_->node_name; |
1013 |
|
|
} |
1014 |
|
|
|
1015 |
|
|
$el->manakai_set_read_only (1, 1); |
1016 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1017 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1018 |
|
|
$el->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]'; |
1019 |
|
|
} |
1020 |
|
|
} |
1021 |
|
|
|
1022 |
|
|
{ |
1023 |
|
|
my $dtd = $doc->create_document_type_definition ('readOnlyDTDef1'); |
1024 |
|
|
my $c1 = $doc->create_processing_instruction ('c1', ''); |
1025 |
|
|
$dtd->append_child ($c1); |
1026 |
|
|
my $c2 = $doc->create_element_type_definition ('c2'); |
1027 |
|
|
$dtd->set_element_type_definition_node ($c2); |
1028 |
|
|
my $c3 = $doc->create_general_entity ('c3'); |
1029 |
|
|
$dtd->set_general_entity_node ($c3); |
1030 |
|
|
my $c4 = $doc->create_notation ('c4'); |
1031 |
|
|
$dtd->set_notation_node ($c4); |
1032 |
|
|
my $c5 = $doc->create_text_node ('c5'); |
1033 |
|
|
$c3->append_child ($c5); |
1034 |
|
|
|
1035 |
|
|
$dtd->manakai_set_read_only (1, 1); |
1036 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1037 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1038 |
|
|
$dtd->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]'; |
1039 |
|
|
} |
1040 |
|
|
|
1041 |
|
|
$dtd->manakai_set_read_only (0, 1); |
1042 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1043 |
|
|
ok $_->manakai_read_only ? 1 : 0, 0, |
1044 |
|
|
$dtd->node_name . '->read_only (1, 0) ' . $_->node_name; |
1045 |
|
|
} |
1046 |
|
|
|
1047 |
|
|
$dtd->manakai_set_read_only (1, 1); |
1048 |
|
|
for ($c1, $c2, $c3, $c4, $c5) { |
1049 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1050 |
|
|
$dtd->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]'; |
1051 |
|
|
} |
1052 |
|
|
} |
1053 |
|
|
|
1054 |
|
|
{ |
1055 |
|
|
my $et = $doc->create_element_type_definition ('readOnlyETDef1'); |
1056 |
|
|
my $c1 = $doc->create_element ('c1'); |
1057 |
|
|
$et->set_attribute_definition_node ($c1); |
1058 |
|
|
my $c2 = $doc->create_text_node ('c2'); |
1059 |
|
|
$c1->append_child ($c2); |
1060 |
|
|
|
1061 |
|
|
$et->manakai_set_read_only (1, 1); |
1062 |
|
|
for ($c1, $c2) { |
1063 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1064 |
|
|
$et->node_name . '->read_only (1, 1) ' . $_->node_name . ' [1]'; |
1065 |
|
|
} |
1066 |
|
|
|
1067 |
|
|
$et->manakai_set_read_only (0, 1); |
1068 |
|
|
for ($c1, $c2) { |
1069 |
|
|
ok $_->manakai_read_only ? 1 : 0, 0, |
1070 |
|
|
$et->node_name . '->read_only (1, 0) ' . $_->node_name; |
1071 |
|
|
} |
1072 |
|
|
|
1073 |
|
|
$et->manakai_set_read_only (1, 1); |
1074 |
|
|
for ($c1, $c2) { |
1075 |
|
|
ok $_->manakai_read_only ? 1 : 0, 1, |
1076 |
|
|
$et->node_name . '->read_only (1, 1) ' . $_->node_name . ' [2]'; |
1077 |
|
|
} |
1078 |
|
|
} |
1079 |
|
|
} |
1080 |
|
|
|
1081 |
|
|
## |manakaiAppendText| |
1082 |
|
|
{ |
1083 |
|
|
my $doc2 = $doc->implementation->create_document; |
1084 |
|
|
|
1085 |
|
|
$doc2->dom_config->set_parameter |
1086 |
|
|
('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 1); |
1087 |
|
|
for my $node ( |
1088 |
|
|
$doc2, |
1089 |
|
|
$doc->create_notation ('Notation_manakaiAppendText'), |
1090 |
|
|
$doc->create_document_type_definition ('DT_manakaiAppendText'), |
1091 |
|
|
$doc->create_element_type_definition ('ET_manakaiAppendText'), |
1092 |
|
|
) { |
1093 |
|
|
ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can'; |
1094 |
|
|
|
1095 |
|
|
$node->manakai_append_text ('aaaa'); |
1096 |
|
|
ok $node->text_content, undef, $node->node_name . ' [1]'; |
1097 |
|
|
ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]'; |
1098 |
|
|
} |
1099 |
|
|
|
1100 |
|
|
$doc2->dom_config->set_parameter |
1101 |
|
|
('http://suika.fam.cx/www/2006/dom-config/strict-document-children' => 0); |
1102 |
|
|
for my $node ( |
1103 |
|
|
$doc->create_attribute ('Attr_manakaiAppendText'), |
1104 |
|
|
$doc->create_element ('Element_manakaiAppendText'), |
1105 |
|
|
$doc2, |
1106 |
|
|
$doc->create_document_fragment, |
1107 |
|
|
$doc->create_general_entity ('Entity_manakaiAppendText'), |
1108 |
|
|
$doc->create_entity_reference ('ER_manakaiAppendText'), |
1109 |
|
|
$doc->create_attribute_definition ('AT_manakaiAppendText'), |
1110 |
|
|
) { |
1111 |
|
|
$node->manakai_set_read_only (0, 1); |
1112 |
|
|
ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can'; |
1113 |
|
|
|
1114 |
|
|
$node->manakai_append_text ('string'); |
1115 |
|
|
ok $node->text_content, 'string', $node->node_name . ' [1]'; |
1116 |
|
|
ok 0+@{$node->child_nodes}, 1, $node->node_name . ' childNodes @{} 0+ [1]'; |
1117 |
|
|
|
1118 |
|
|
$node->manakai_append_text ('STRING'); |
1119 |
|
|
ok $node->text_content, 'stringSTRING', $node->node_name . ' [2]'; |
1120 |
|
|
ok 0+@{$node->child_nodes}, 1, $node->node_name . ' childNodes @{} 0+ [2]'; |
1121 |
|
|
|
1122 |
|
|
my $er = $doc->create_entity_reference ('er'); |
1123 |
|
|
$node->append_child ($er); |
1124 |
|
|
|
1125 |
|
|
$node->manakai_append_text ('text'); |
1126 |
|
|
ok $node->text_content, 'stringSTRINGtext', $node->node_name . ' [3]'; |
1127 |
|
|
ok 0+@{$node->child_nodes}, 3, $node->node_name . ' childNodes @{} 0+ [3]'; |
1128 |
|
|
} |
1129 |
|
|
|
1130 |
|
|
for my $node ( |
1131 |
|
|
$doc->create_text_node (''), |
1132 |
|
|
$doc->create_cdata_section (''), |
1133 |
|
|
$doc->create_comment (''), |
1134 |
|
|
$doc->create_processing_instruction ('PI_manakaiAppendText'), |
1135 |
|
|
) { |
1136 |
|
|
ok $node->can ('manakai_append_text') ? 1 : 0, 1, $node->node_name . 'can'; |
1137 |
|
|
|
1138 |
|
|
$node->manakai_append_text ('aaaa'); |
1139 |
|
|
ok $node->text_content, 'aaaa', $node->node_name . ' [1]'; |
1140 |
|
|
ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]'; |
1141 |
|
|
|
1142 |
|
|
$node->manakai_append_text ('bbbb'); |
1143 |
|
|
ok $node->text_content, 'aaaabbbb', $node->node_name . ' [1]'; |
1144 |
|
|
ok 0+@{$node->child_nodes}, 0, $node->node_name . ' childNodes @{} 0+ [1]'; |
1145 |
|
|
} |
1146 |
|
|
} |
1147 |
|
|
|
1148 |
|
|
## |baseURI| |
1149 |
|
|
{ |
1150 |
|
|
my $doc2 = $doc->implementation->create_document; |
1151 |
|
|
|
1152 |
|
|
$doc2->document_uri (q<ftp://suika.fam.cx/>); |
1153 |
|
|
ok $doc2->base_uri, q<ftp://suika.fam.cx/>, 'Document->base_uri [1]'; |
1154 |
|
|
|
1155 |
|
|
$doc2->document_uri (undef); |
1156 |
|
|
ok $doc2->base_uri, undef, 'Document->base_uri [2]'; |
1157 |
|
|
ok $doc2->manakai_entity_base_uri, undef, 'Document->base_uri ebu [2]'; |
1158 |
|
|
|
1159 |
|
|
$doc2->manakai_entity_base_uri (q<https://suika.fam.cx/>); |
1160 |
|
|
ok $doc2->base_uri, q<https://suika.fam.cx/>, 'Document->base_uri [3]'; |
1161 |
|
|
ok $doc2->manakai_entity_base_uri, q<https://suika.fam.cx/>, |
1162 |
|
|
'Document->base_uri ebu [3]'; |
1163 |
|
|
|
1164 |
|
|
$doc2->manakai_entity_base_uri (undef); |
1165 |
|
|
ok $doc2->base_uri, undef, 'Document->base_uri [4]'; |
1166 |
|
|
ok $doc2->manakai_entity_base_uri, undef, 'Document->base_uri ebu [4]'; |
1167 |
|
|
|
1168 |
|
|
$doc2->document_uri (q<ftp://suika.fam.cx/>); |
1169 |
|
|
$doc2->manakai_entity_base_uri (q<https://suika.fam.cx/>); |
1170 |
|
|
ok $doc2->base_uri, q<https://suika.fam.cx/>, 'Document->base_uri [5]'; |
1171 |
|
|
ok $doc2->manakai_entity_base_uri, q<https://suika.fam.cx/>, |
1172 |
|
|
'Document->base_uri ebu [5]'; |
1173 |
|
|
} |
1174 |
|
|
|
1175 |
|
|
for my $method (qw/ |
1176 |
|
|
create_document_fragment |
1177 |
|
|
create_element_type_definition |
1178 |
|
|
create_attribute_definition |
1179 |
|
|
/) { |
1180 |
|
|
my $doc2 = $doc->implementation->create_document; |
1181 |
|
|
|
1182 |
|
|
my $node = $doc2->$method ('a'); |
1183 |
|
|
|
1184 |
|
|
$doc2->document_uri (q<ftp://doc.test/>); |
1185 |
|
|
ok $node->base_uri, q<ftp://doc.test/>, $node->node_name . '->base_uri [1]'; |
1186 |
|
|
|
1187 |
|
|
$doc2->manakai_entity_base_uri (q<ftp://suika.fam.cx/>); |
1188 |
|
|
ok $node->base_uri, q<ftp://suika.fam.cx/>, |
1189 |
|
|
$node->node_name . '->base_uri [2]'; |
1190 |
|
|
} |
1191 |
|
|
|
1192 |
|
|
{ |
1193 |
|
|
my $doc2 = $doc->implementation->create_document; |
1194 |
|
|
|
1195 |
|
|
my $attr = $doc2->create_attribute_ns (undef, 'attr'); |
1196 |
|
|
|
1197 |
|
|
$doc2->document_uri (q<http://www.example.com/>); |
1198 |
|
|
ok $attr->base_uri, q<http://www.example.com/>, 'Attr->base_uri [1]'; |
1199 |
|
|
|
1200 |
|
|
my $el = $doc2->create_element_ns (undef, 'element'); |
1201 |
|
|
$el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', |
1202 |
|
|
'xml:base' => q<http://www.example.org/>); |
1203 |
|
|
$el->set_attribute_node_ns ($attr); |
1204 |
|
|
ok $attr->base_uri, q<http://www.example.org/>, 'Attr->base_uri [2]'; |
1205 |
|
|
} |
1206 |
|
|
|
1207 |
|
|
for my $i (0..1) { |
1208 |
|
|
my $xb = [ |
1209 |
|
|
['http://www.w3.org/XML/1998/namespace', 'xml:base'], |
1210 |
|
|
[undef, [undef, 'xml:base']], |
1211 |
|
|
]->[$i]; |
1212 |
|
|
|
1213 |
|
|
my $doc2 = $doc->implementation->create_document; |
1214 |
wakaba |
1.8 |
$doc2->strict_error_checking (0); |
1215 |
wakaba |
1.4 |
|
1216 |
|
|
my $attr = $doc2->create_attribute_ns (@$xb); |
1217 |
|
|
$attr->value (q<http://attr.test/>); |
1218 |
|
|
|
1219 |
|
|
ok $attr->base_uri, undef, 'xml:base->base_uri [0]' . $i; |
1220 |
|
|
|
1221 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1222 |
|
|
ok $attr->base_uri, q<http://doc.test/>, 'xml:base->base_uri [1]' . $i; |
1223 |
|
|
|
1224 |
|
|
my $el = $doc2->create_element_ns (undef, 'e'); |
1225 |
|
|
$el->set_attribute_node_ns ($attr); |
1226 |
|
|
ok $attr->base_uri, q<http://doc.test/>, 'xml:base->base_uri [2]' . $i; |
1227 |
|
|
|
1228 |
|
|
my $pel = $doc2->create_element_ns (undef, 'e'); |
1229 |
|
|
$pel->set_attribute_ns (@$xb, q<http://pel.test/>); |
1230 |
|
|
$pel->append_child ($el); |
1231 |
|
|
ok $attr->base_uri, q<http://pel.test/>, 'xml:base->base_uri [3]' . $i; |
1232 |
|
|
} |
1233 |
|
|
|
1234 |
|
|
for my $i (0..1) { |
1235 |
|
|
my $xb = [ |
1236 |
|
|
['http://www.w3.org/XML/1998/namespace', 'xml:base'], |
1237 |
|
|
[undef, [undef, 'xml:base']], |
1238 |
|
|
]->[$i]; |
1239 |
|
|
|
1240 |
|
|
my $doc2 = $doc->implementation->create_document; |
1241 |
|
|
|
1242 |
|
|
my $el = $doc2->create_element_ns (undef, 'el'); |
1243 |
|
|
|
1244 |
|
|
ok $el->base_uri, undef, "Element->base_uri [0]"; |
1245 |
|
|
ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [0]"; |
1246 |
|
|
|
1247 |
|
|
$doc2->document_uri (q<http://foo.example/>); |
1248 |
|
|
ok $el->base_uri, q<http://foo.example/>, "Element->base_uri [1]"; |
1249 |
|
|
ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [1]"; |
1250 |
|
|
|
1251 |
|
|
$el->set_attribute_ns (@$xb => q<http://www.example.com/>); |
1252 |
|
|
ok $el->base_uri, q<http://www.example.com/>, "Element->base_uri [2]"; |
1253 |
|
|
ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [2]"; |
1254 |
|
|
|
1255 |
|
|
$el->set_attribute_ns (@$xb => q<bar>); |
1256 |
|
|
ok $el->base_uri, q<http://foo.example/bar>, "Element->base_uri [3]"; |
1257 |
|
|
ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [3]"; |
1258 |
|
|
|
1259 |
|
|
$el->manakai_base_uri (q<http://baz.example/>); |
1260 |
|
|
ok $el->base_uri, q<http://baz.example/>, "Element->base_uri [4]"; |
1261 |
|
|
ok $el->manakai_base_uri, q<http://baz.example/>, |
1262 |
|
|
"Element->manakai_base_uri [4]"; |
1263 |
|
|
|
1264 |
|
|
$el->manakai_base_uri (undef); |
1265 |
|
|
ok $el->base_uri, q<http://foo.example/bar>, "Element->base_uri [5]"; |
1266 |
|
|
ok $el->manakai_base_uri, undef, "Element->manakai_base_uri [5]"; |
1267 |
|
|
} |
1268 |
|
|
|
1269 |
|
|
{ |
1270 |
|
|
my $doc2 = $doc->implementation->create_document; |
1271 |
|
|
|
1272 |
|
|
my $el = $doc2->create_element_ns (undef, 'el'); |
1273 |
|
|
|
1274 |
|
|
ok $el->base_uri, undef, "Element->base_uri [6]"; |
1275 |
|
|
|
1276 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1277 |
|
|
ok $el->base_uri, q<http://doc.test/>, "Element->base_uri [7]"; |
1278 |
|
|
|
1279 |
|
|
my $el0 = $doc2->create_element_ns (undef, 'e'); |
1280 |
|
|
$el0->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base', |
1281 |
|
|
q<http://el.test/>); |
1282 |
|
|
$el0->append_child ($el); |
1283 |
|
|
ok $el->base_uri, q<http://el.test/>, "Element->base_uri [8]"; |
1284 |
|
|
|
1285 |
|
|
my $ent = $doc2->create_entity_reference ('ent'); |
1286 |
|
|
$ent->manakai_set_read_only (0, 1); |
1287 |
|
|
$ent->manakai_external (1); |
1288 |
|
|
$ent->manakai_entity_base_uri (q<http://ent.test/>); |
1289 |
|
|
$el0->append_child ($ent); |
1290 |
|
|
$ent->append_child ($el); |
1291 |
|
|
ok $el->base_uri, q<http://ent.test/>, "Element->base_uri [9]"; |
1292 |
|
|
} |
1293 |
|
|
|
1294 |
|
|
for (qw/create_text_node create_cdata_section create_comment/) { |
1295 |
|
|
my $doc2 = $doc->implementation->create_document; |
1296 |
|
|
my $node = $doc2->$_ (''); |
1297 |
|
|
|
1298 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1299 |
|
|
ok $node->base_uri, q<http://doc.test/>, $node->node_name . "->base_uri [0]"; |
1300 |
|
|
|
1301 |
|
|
my $el = $doc2->create_element_ns (undef, 'e'); |
1302 |
|
|
$el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base', |
1303 |
|
|
q<http://el.test/>); |
1304 |
|
|
$el->append_child ($node); |
1305 |
|
|
ok $node->base_uri, q<http://el.test/>, $node->node_name . "->base_uri [1]"; |
1306 |
|
|
|
1307 |
|
|
my $ent = $doc2->create_entity_reference ('ent'); |
1308 |
|
|
$ent->manakai_set_read_only (0, 1); |
1309 |
|
|
$ent->manakai_external (1); |
1310 |
|
|
$ent->manakai_entity_base_uri (q<http://ent.test/>); |
1311 |
|
|
$el->append_child ($ent); |
1312 |
|
|
$ent->append_child ($node); |
1313 |
|
|
ok $node->base_uri, q<http://ent.test/>, $node->node_name . "->base_uri [2]"; |
1314 |
|
|
} |
1315 |
|
|
|
1316 |
|
|
{ |
1317 |
|
|
my $doc2 = $doc->implementation->create_document; |
1318 |
|
|
my $ent = $doc2->create_general_entity ('ent'); |
1319 |
|
|
|
1320 |
|
|
$doc2->document_uri (q<http://base.example/>); |
1321 |
|
|
ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [1]"; |
1322 |
|
|
|
1323 |
|
|
$ent->manakai_entity_base_uri (q<http://www.example.com/>); |
1324 |
|
|
ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [2]"; |
1325 |
|
|
|
1326 |
|
|
$ent->manakai_declaration_base_uri (q<http://www.example/>); |
1327 |
|
|
ok $ent->base_uri, q<http://base.example/>, "Entity->base_uri [3]"; |
1328 |
|
|
} |
1329 |
|
|
|
1330 |
|
|
{ |
1331 |
|
|
my $doc2 = $doc->implementation->create_document; |
1332 |
|
|
|
1333 |
|
|
my $ent = $doc2->create_entity_reference ('ent'); |
1334 |
|
|
$ent->manakai_set_read_only (0, 1); |
1335 |
|
|
|
1336 |
|
|
$doc2->document_uri (q<http://base.example/>); |
1337 |
|
|
ok $ent->base_uri, q<http://base.example/>, "ER->base_uri [1]"; |
1338 |
|
|
|
1339 |
|
|
$ent->manakai_entity_base_uri (q<http://www.example.com/>); |
1340 |
|
|
ok $ent->base_uri, q<http://base.example/>; |
1341 |
|
|
|
1342 |
|
|
my $el = $doc2->create_element_ns (undef, 'el'); |
1343 |
|
|
$el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base', |
1344 |
|
|
q<http://el.test/>); |
1345 |
|
|
$el->append_child ($ent); |
1346 |
|
|
ok $ent->base_uri, q<http://el.test/>, "ER->base_uri [2]"; |
1347 |
|
|
|
1348 |
|
|
my $xent = $doc2->create_entity_reference ('ext'); |
1349 |
|
|
$xent->manakai_set_read_only (0, 1); |
1350 |
|
|
$xent->manakai_entity_base_uri (q<http://ent.test/>); |
1351 |
|
|
$xent->manakai_external (1); |
1352 |
|
|
$el->append_child ($xent); |
1353 |
|
|
$xent->append_child ($ent); |
1354 |
|
|
ok $ent->base_uri, q<http://ent.test/>, "ER->base_uri [3]"; |
1355 |
|
|
} |
1356 |
|
|
|
1357 |
|
|
{ |
1358 |
|
|
my $doc2 = $doc->implementation->create_document; |
1359 |
|
|
|
1360 |
|
|
my $pi = $doc2->create_processing_instruction ('i'); |
1361 |
|
|
|
1362 |
|
|
ok $pi->base_uri, undef, "PI->base_uri [0]"; |
1363 |
|
|
ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [0]"; |
1364 |
|
|
|
1365 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1366 |
|
|
ok $pi->base_uri, q<http://doc.test/>, "PI->base_uri [1]"; |
1367 |
|
|
ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [1]"; |
1368 |
|
|
|
1369 |
|
|
my $el = $doc2->create_element_ns (undef, 'e'); |
1370 |
|
|
$el->set_attribute_ns ('http://www.w3.org/XML/1998/namespace', 'xml:base', |
1371 |
|
|
q<http://el.test/>); |
1372 |
|
|
$el->append_child ($pi); |
1373 |
|
|
ok $pi->base_uri, q<http://el.test/>, "PI->base_uri [2]"; |
1374 |
|
|
ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [2]"; |
1375 |
|
|
|
1376 |
|
|
my $ent = $doc2->create_entity_reference ('ent'); |
1377 |
|
|
$ent->manakai_set_read_only (0, 1); |
1378 |
|
|
$ent->manakai_external (1); |
1379 |
|
|
$ent->manakai_entity_base_uri (q<http://ent.test/>); |
1380 |
|
|
$el->append_child ($ent); |
1381 |
|
|
$ent->append_child ($pi); |
1382 |
|
|
ok $pi->base_uri, q<http://ent.test/>, "PI->base_uri [3]"; |
1383 |
|
|
ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [3]"; |
1384 |
|
|
|
1385 |
|
|
$pi->manakai_base_uri (q<http://pi.ent/>); |
1386 |
|
|
ok $pi->base_uri, q<http://pi.ent/>, "PI->base_uri [4]"; |
1387 |
|
|
ok $pi->manakai_base_uri, q<http://pi.ent/>, "PI->manakai_base_uri [4]"; |
1388 |
|
|
|
1389 |
|
|
$pi->manakai_base_uri (undef); |
1390 |
|
|
ok $pi->base_uri, q<http://ent.test/>, "PI->base_uri [5]"; |
1391 |
|
|
ok $pi->manakai_base_uri, undef, "PI->manakai_base_uri [5]"; |
1392 |
|
|
} |
1393 |
|
|
|
1394 |
|
|
{ |
1395 |
|
|
my $doc2 = $doc->implementation->create_document; |
1396 |
|
|
|
1397 |
|
|
my $pi = $doc2->create_notation ('i'); |
1398 |
|
|
|
1399 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1400 |
|
|
ok $pi->base_uri, q<http://doc.test/>, "Notation->base_uri [1]"; |
1401 |
|
|
|
1402 |
|
|
$pi->manakai_declaration_base_uri (q<http://www.example/>); |
1403 |
|
|
ok $pi->base_uri, q<http://doc.test/>, "Notation->base_uri [2]"; |
1404 |
|
|
} |
1405 |
|
|
|
1406 |
|
|
{ |
1407 |
|
|
my $dt = $doc->implementation->create_document_type ('name'); |
1408 |
|
|
ok $dt->base_uri, undef, "DT->base_uri [0]"; |
1409 |
|
|
|
1410 |
|
|
my $doc2 = $doc->implementation->create_document; |
1411 |
|
|
$doc2->append_child ($dt); |
1412 |
|
|
$doc2->document_uri (q<http://doc.test/>); |
1413 |
|
|
ok $dt->owner_document, $doc2; |
1414 |
|
|
ok $dt->base_uri, q<http://doc.test/>, "DT->base_uri [1]"; |
1415 |
|
|
} |
1416 |
|
|
|
1417 |
wakaba |
1.6 |
## |hasAttribute| |
1418 |
|
|
{ |
1419 |
|
|
my $el = $doc->create_element ('e'); |
1420 |
|
|
ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [0]"; |
1421 |
|
|
|
1422 |
|
|
$el->set_attribute (a => 'b'); |
1423 |
|
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [1]"; |
1424 |
|
|
|
1425 |
|
|
$el->set_attribute (c => 'd'); |
1426 |
|
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [2]"; |
1427 |
|
|
|
1428 |
|
|
$el->remove_attribute ('c'); |
1429 |
|
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [3]"; |
1430 |
|
|
|
1431 |
|
|
$el->get_attribute_node ('a')->specified (0); |
1432 |
|
|
ok $el->has_attributes ? 1 : 0, 1, "Element->has_attributes [4]"; |
1433 |
|
|
|
1434 |
|
|
$el->remove_attribute ('a'); |
1435 |
|
|
ok $el->has_attributes ? 1 : 0, 0, "Element->has_attributes [5]"; |
1436 |
|
|
} |
1437 |
|
|
|
1438 |
|
|
## |hasChildNodes| |
1439 |
|
|
{ |
1440 |
|
|
my $doc2 = $doc->implementation->create_document; |
1441 |
|
|
|
1442 |
|
|
ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [0]"; |
1443 |
|
|
|
1444 |
|
|
$doc2->append_child ($doc2->create_comment ('')); |
1445 |
|
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [1]"; |
1446 |
|
|
|
1447 |
|
|
$doc2->append_child ($doc2->create_comment ('')); |
1448 |
|
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [2]"; |
1449 |
|
|
|
1450 |
|
|
$doc2->remove_child ($doc2->first_child); |
1451 |
|
|
ok $doc2->has_child_nodes ? 1 : 0, 1, "Document->has_child_nodes [3]"; |
1452 |
|
|
|
1453 |
|
|
$doc2->remove_child ($doc2->first_child); |
1454 |
|
|
ok $doc2->has_child_nodes ? 1 : 0, 0, "Document->has_child_nodes [4]"; |
1455 |
|
|
} |
1456 |
|
|
|
1457 |
|
|
## |compareDocumentPosition| |
1458 |
|
|
{ |
1459 |
|
|
my $e1 = $doc->create_element ('e1'); |
1460 |
|
|
my $e2 = $doc->create_element ('e2'); |
1461 |
|
|
|
1462 |
|
|
my $dp2 = $e1->compare_document_position ($e2); |
1463 |
|
|
|
1464 |
|
|
ok $dp2 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [1]"; |
1465 |
|
|
ok $dp2 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "edp [2]"; |
1466 |
|
|
ok (($dp2 & $e1->DOCUMENT_POSITION_PRECEDING || |
1467 |
|
|
$dp2 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [3]"); |
1468 |
|
|
|
1469 |
|
|
my $dp1 = $e2->compare_document_position ($e1); |
1470 |
|
|
|
1471 |
|
|
ok $dp1 & $e1->DOCUMENT_POSITION_DISCONNECTED ? 1 : 0, 1, "cdp [4]"; |
1472 |
|
|
ok $dp1 & $e1->DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC ? 1 : 0, 1, "cdp [5]"; |
1473 |
|
|
ok (($dp1 & $e1->DOCUMENT_POSITION_PRECEDING || |
1474 |
|
|
$dp1 & $e1->DOCUMENT_POSITION_FOLLOWING) ? 1 : 0, 1, "cdp [6]"); |
1475 |
|
|
} |
1476 |
|
|
|
1477 |
|
|
{ |
1478 |
|
|
my $e1 = $doc->create_element ('e1'); |
1479 |
|
|
my $e2 = $doc->create_element ('e2'); |
1480 |
|
|
|
1481 |
|
|
my $pe = $doc->create_element ('pe'); |
1482 |
|
|
$pe->append_child ($e1); |
1483 |
|
|
$pe->append_child ($e2); |
1484 |
|
|
|
1485 |
|
|
my $dp2 = $e1->compare_document_position ($e2); |
1486 |
|
|
|
1487 |
|
|
ok $dp2 & $e1->DOCUMENT_POSITION_FOLLOWING ? 1 : 0, 1, "cde [7]"; |
1488 |
|
|
|
1489 |
|
|
my $dp1 = $e2->compare_document_position ($e1); |
1490 |
|
|
|
1491 |
|
|
ok $dp1 & $e1->DOCUMENT_POSITION_PRECEDING ? 1 : 0, 1, "cde [8]"; |
1492 |
|
|
} |
1493 |
|
|
## TODO: Apparently compare_document_position requires more tests. |
1494 |
|
|
|
1495 |
|
|
## |lookupNamespaceURI| |
1496 |
|
|
{ |
1497 |
|
|
for my $node (create_nodes ()) { |
1498 |
|
|
ok $node->lookup_namespace_uri ('ns1'), undef, $node->node_name . " lnu [0]"; |
1499 |
|
|
ok $node->lookup_namespace_uri ('xml'), undef, $node->node_name . " lnu [1]"; |
1500 |
|
|
ok $node->lookup_namespace_uri ('xmlns'), undef, $node->node_name . " lnu [2]"; |
1501 |
|
|
ok $node->lookup_namespace_uri (''), undef, $node->node_name . " lnu [3]"; |
1502 |
|
|
ok $node->lookup_namespace_uri (undef), undef, $node->node_name . " lnu [4]"; |
1503 |
|
|
} |
1504 |
|
|
|
1505 |
|
|
my $el = $doc->create_element_ns ('about:', 'el'); |
1506 |
|
|
ok $el->lookup_namespace_uri ('ns1'), undef, 'Element->lnu [0]'; |
1507 |
|
|
|
1508 |
|
|
$el->prefix ('ns1'); |
1509 |
|
|
ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [1]'; |
1510 |
|
|
|
1511 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:ns1', 'DAV:'); |
1512 |
|
|
ok $el->lookup_namespace_uri ('ns1'), 'about:', 'Element->lnu [2]'; |
1513 |
|
|
|
1514 |
|
|
$el->prefix (undef); |
1515 |
|
|
ok $el->lookup_namespace_uri ('ns1'), 'DAV:', 'Element->lnu [3]'; |
1516 |
|
|
} |
1517 |
|
|
|
1518 |
|
|
## |lookupPrefix| |
1519 |
|
|
{ |
1520 |
|
|
for my $node (create_nodes ()) { |
1521 |
|
|
ok $node->lookup_prefix ('http://test/'), undef, $node->node_name . "lp [0]"; |
1522 |
|
|
ok $node->lookup_prefix ('http://www.w3.org/XML/1998/namespace'), undef, $node->node_name . "lp [1]"; |
1523 |
|
|
ok $node->lookup_prefix ('http://www.w3.org/2000/xmlns/'), undef, $node->node_name . "lp [2]"; |
1524 |
|
|
ok $node->lookup_prefix ('http://www.w3.org/1999/xhtml'), undef, $node->node_name . "lp [3]"; |
1525 |
|
|
ok $node->lookup_prefix (''), undef, $node->node_name . "lp [4]"; |
1526 |
|
|
ok $node->lookup_prefix (undef), undef, $node->node_name . "lp [5]"; |
1527 |
|
|
} |
1528 |
|
|
|
1529 |
|
|
my $el = $doc->create_element_ns ('http://test/', 'e'); |
1530 |
|
|
ok $el->lookup_prefix ('ns'), undef, "Element->lp [0]";; |
1531 |
|
|
|
1532 |
|
|
my $el2 = $doc->create_element_ns ('http://test/', 'f'); |
1533 |
|
|
$el2->append_child ($el); |
1534 |
|
|
$el2->prefix ('ns'); |
1535 |
|
|
ok $el->lookup_prefix ('http://test/'), 'ns', "Element->lp [1]"; |
1536 |
|
|
|
1537 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns:a', |
1538 |
|
|
'http://test/'); |
1539 |
|
|
ok $el->lookup_prefix ('http://test/'), 'a', "Element->lp [2]"; |
1540 |
|
|
|
1541 |
|
|
$el->prefix ('b'); |
1542 |
|
|
ok $el->lookup_prefix ('http://test/'), 'b', "Element->lp [3]"; |
1543 |
|
|
} |
1544 |
|
|
|
1545 |
|
|
## |isDefaultNamespace| |
1546 |
|
|
{ |
1547 |
|
|
for my $node (create_nodes ()) { |
1548 |
|
|
next if $node->node_type == 1; |
1549 |
|
|
ok $node->is_default_namespace ('about:') ? 1 : 0, 0, $node->node_name."idn[0]"; |
1550 |
|
|
ok $node->is_default_namespace ('http://www.w3.org/XML/1998/namespace') ? 1 : 0, 0, $node->node_name."idn[2]"; |
1551 |
|
|
ok $node->is_default_namespace ('http://www.w3.org/2000/xmlns/') ? 1 : 0, 0, $node->node_name."idn[3]"; |
1552 |
|
|
ok $node->is_default_namespace ('') ? 1 : 0, 0, $node->node_name."idn[4]"; |
1553 |
|
|
ok $node->is_default_namespace (undef) ? 1 : 0, 0, $node->node_name."idn[5]"; |
1554 |
|
|
} |
1555 |
|
|
|
1556 |
|
|
my $el = $doc->create_element_ns ('about:', 'el'); |
1557 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [0]"; |
1558 |
|
|
|
1559 |
|
|
$el->prefix ('ns1'); |
1560 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [1]"; |
1561 |
|
|
|
1562 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1563 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [2]"; |
1564 |
|
|
|
1565 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:'); |
1566 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [3]"; |
1567 |
|
|
|
1568 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1569 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [4]"; |
1570 |
|
|
} |
1571 |
|
|
|
1572 |
|
|
{ |
1573 |
|
|
my $el = $doc->create_element_ns ('about:', 'p:el'); |
1574 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [5]"; |
1575 |
|
|
|
1576 |
|
|
$el->prefix ('ns1'); |
1577 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [6]"; |
1578 |
|
|
|
1579 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1580 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [7]"; |
1581 |
|
|
|
1582 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'about:'); |
1583 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 1, "Element->idn [8]"; |
1584 |
|
|
|
1585 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1586 |
|
|
ok $el->is_default_namespace ('about:') ? 1 : 0, 0, "Element->idn [9]"; |
1587 |
|
|
} |
1588 |
|
|
|
1589 |
|
|
{ |
1590 |
|
|
my $el = $doc->create_element ('e'); |
1591 |
|
|
|
1592 |
|
|
## NOTE: This might look like strange, but it is how it is defined! |
1593 |
|
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [10]"; |
1594 |
|
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [11]"; |
1595 |
|
|
|
1596 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', 'DAV:'); |
1597 |
|
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [12]"; |
1598 |
|
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [13]"; |
1599 |
|
|
|
1600 |
|
|
$el->set_attribute_ns ('http://www.w3.org/2000/xmlns/', 'xmlns', ''); |
1601 |
|
|
ok $el->is_default_namespace (undef) ? 1 : 0, 0, "Element->idn [14]"; |
1602 |
|
|
ok $el->is_default_namespace ('') ? 1 : 0, 0, "Element->idn [15]"; |
1603 |
|
|
} |
1604 |
|
|
|
1605 |
|
|
## |manakaiParentElement| |
1606 |
|
|
{ |
1607 |
|
|
my $el = $doc->create_element ('el'); |
1608 |
|
|
ok $el->manakai_parent_element, undef, "mpe [0]"; |
1609 |
|
|
|
1610 |
|
|
my $el2 = $doc->create_element ('el2'); |
1611 |
|
|
$el->append_child ($el2); |
1612 |
|
|
ok $el2->manakai_parent_element, $el, "mpe [1]"; |
1613 |
|
|
|
1614 |
|
|
my $er1 = $doc->create_entity_reference ('er1'); |
1615 |
|
|
$er1->manakai_set_read_only (0, 1); |
1616 |
|
|
$el->append_child ($er1); |
1617 |
|
|
$er1->append_child ($el2); |
1618 |
|
|
ok $el2->manakai_parent_element, $el, "mpe [1]"; |
1619 |
|
|
} |
1620 |
|
|
|
1621 |
|
|
{ |
1622 |
|
|
my $el = $doc->create_element ('el'); |
1623 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1624 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1625 |
|
|
$el->append_child ($t1); |
1626 |
|
|
$el->append_child ($t2); |
1627 |
|
|
$el->normalize; |
1628 |
|
|
|
1629 |
|
|
ok $el->text_content, 't1t2', 'normalize [0]'; |
1630 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [1]'; |
1631 |
|
|
} |
1632 |
|
|
|
1633 |
|
|
{ |
1634 |
|
|
my $el = $doc->create_element ('el'); |
1635 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1636 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1637 |
|
|
my $t3 = $doc->create_text_node ('t3'); |
1638 |
|
|
my $t4 = $doc->create_text_node ('t4'); |
1639 |
|
|
$el->append_child ($t1); |
1640 |
|
|
$el->append_child ($t2); |
1641 |
|
|
$el->append_child ($t3); |
1642 |
|
|
$el->append_child ($t4); |
1643 |
|
|
$el->normalize; |
1644 |
|
|
|
1645 |
|
|
ok $el->text_content, 't1t2t3t4', 'normalize [2]'; |
1646 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [3]'; |
1647 |
|
|
} |
1648 |
|
|
|
1649 |
|
|
{ |
1650 |
|
|
my $el = $doc->create_element ('el'); |
1651 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1652 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1653 |
|
|
my $c1 = $doc->create_cdata_section ('c1'); |
1654 |
|
|
my $t3 = $doc->create_text_node ('t3'); |
1655 |
|
|
my $t4 = $doc->create_text_node ('t4'); |
1656 |
|
|
$el->append_child ($t1); |
1657 |
|
|
$el->append_child ($t2); |
1658 |
|
|
$el->append_child ($c1); |
1659 |
|
|
$el->append_child ($t3); |
1660 |
|
|
$el->append_child ($t4); |
1661 |
|
|
$el->normalize; |
1662 |
|
|
|
1663 |
|
|
ok $el->text_content, 't1t2c1t3t4', 'normalize [4]'; |
1664 |
|
|
ok 0+@{$el->child_nodes}, 3, 'normalize [5]'; |
1665 |
|
|
ok $el->first_child->text_content, 't1t2', 'normalize [6]'; |
1666 |
|
|
ok $el->last_child->text_content, 't3t4', 'normalize [7]'; |
1667 |
|
|
} |
1668 |
|
|
|
1669 |
|
|
{ |
1670 |
|
|
my $el = $doc->create_element ('el'); |
1671 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1672 |
|
|
my $t2 = $doc->create_text_node (''); |
1673 |
|
|
$el->append_child ($t1); |
1674 |
|
|
$el->append_child ($t2); |
1675 |
|
|
$el->normalize; |
1676 |
|
|
|
1677 |
|
|
ok $el->text_content, 't1', 'normalize [8]'; |
1678 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [9]'; |
1679 |
|
|
} |
1680 |
|
|
|
1681 |
|
|
{ |
1682 |
|
|
my $el = $doc->create_element ('el'); |
1683 |
|
|
my $t1 = $doc->create_text_node (''); |
1684 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1685 |
|
|
$el->append_child ($t1); |
1686 |
|
|
$el->append_child ($t2); |
1687 |
|
|
$el->normalize; |
1688 |
|
|
|
1689 |
|
|
ok $el->text_content, 't2', 'normalize [10]'; |
1690 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [11]'; |
1691 |
|
|
} |
1692 |
|
|
|
1693 |
|
|
{ |
1694 |
|
|
my $el = $doc->create_element ('el'); |
1695 |
|
|
my $t1 = $doc->create_text_node (''); |
1696 |
|
|
$el->append_child ($t1); |
1697 |
|
|
$el->normalize; |
1698 |
|
|
|
1699 |
|
|
ok $el->text_content, '', 'normalize [12]'; |
1700 |
|
|
ok 0+@{$el->child_nodes}, 0, 'normalize [13]'; |
1701 |
|
|
} |
1702 |
|
|
|
1703 |
|
|
{ |
1704 |
|
|
my $pe = $doc->create_element ('pe'); |
1705 |
|
|
my $el = $doc->create_element ('el'); |
1706 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1707 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1708 |
|
|
$el->append_child ($t1); |
1709 |
|
|
$el->append_child ($t2); |
1710 |
|
|
$pe->append_child ($el); |
1711 |
|
|
$pe->normalize; |
1712 |
|
|
|
1713 |
|
|
ok $el->text_content, 't1t2', 'normalize [14]'; |
1714 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [15]'; |
1715 |
|
|
} |
1716 |
|
|
|
1717 |
|
|
{ |
1718 |
|
|
my $pe = $doc->create_element ('pe'); |
1719 |
|
|
my $el = $doc->create_attribute ('a'); |
1720 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1721 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1722 |
|
|
$el->append_child ($t1); |
1723 |
|
|
$el->append_child ($t2); |
1724 |
|
|
$pe->set_attribute_node ($el); |
1725 |
|
|
$pe->normalize; |
1726 |
|
|
|
1727 |
|
|
ok $el->text_content, 't1t2', 'normalize [16]'; |
1728 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [17]'; |
1729 |
|
|
} |
1730 |
|
|
|
1731 |
|
|
{ |
1732 |
|
|
my $pe = $doc->create_element_type_definition ('pe'); |
1733 |
|
|
my $el = $doc->create_attribute_definition ('a'); |
1734 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1735 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1736 |
|
|
$el->append_child ($t1); |
1737 |
|
|
$el->append_child ($t2); |
1738 |
|
|
$pe->set_attribute_definition_node ($el); |
1739 |
|
|
$pe->normalize; |
1740 |
|
|
|
1741 |
|
|
ok $el->text_content, 't1t2', 'normalize [16]'; |
1742 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [17]'; |
1743 |
|
|
} |
1744 |
|
|
|
1745 |
|
|
{ |
1746 |
|
|
my $dt = $doc->create_document_type_definition ('dt'); |
1747 |
|
|
my $pe = $doc->create_element_type_definition ('pe'); |
1748 |
|
|
my $el = $doc->create_attribute_definition ('a'); |
1749 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1750 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1751 |
|
|
$el->append_child ($t1); |
1752 |
|
|
$el->append_child ($t2); |
1753 |
|
|
$pe->set_attribute_definition_node ($el); |
1754 |
|
|
$dt->set_element_type_definition_node ($pe); |
1755 |
|
|
$dt->normalize; |
1756 |
|
|
|
1757 |
|
|
ok $el->text_content, 't1t2', 'normalize [18]'; |
1758 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [19]'; |
1759 |
|
|
} |
1760 |
|
|
|
1761 |
|
|
{ |
1762 |
|
|
my $pe = $doc->create_document_type_definition ('pe'); |
1763 |
|
|
my $el = $doc->create_general_entity ('a'); |
1764 |
|
|
my $t1 = $doc->create_text_node ('t1'); |
1765 |
|
|
my $t2 = $doc->create_text_node ('t2'); |
1766 |
|
|
$el->append_child ($t1); |
1767 |
|
|
$el->append_child ($t2); |
1768 |
|
|
$pe->set_general_entity_node ($el); |
1769 |
|
|
$pe->normalize; |
1770 |
|
|
|
1771 |
|
|
ok $el->text_content, 't1t2', 'normalize [20]'; |
1772 |
|
|
ok 0+@{$el->child_nodes}, 1, 'normalize [21]'; |
1773 |
|
|
} |
1774 |
wakaba |
1.4 |
|
1775 |
wakaba |
1.2 |
## TODO: parent_node tests, as with append_child tests |
1776 |
|
|
|
1777 |
wakaba |
1.3 |
## TODO: text_content tests for CharacterData and PI |
1778 |
|
|
|
1779 |
wakaba |
1.4 |
=head1 LICENSE |
1780 |
|
|
|
1781 |
|
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
1782 |
wakaba |
1.3 |
|
1783 |
wakaba |
1.4 |
This program is free software; you can redistribute it and/or |
1784 |
|
|
modify it under the same terms as Perl itself. |
1785 |
wakaba |
1.2 |
|
1786 |
wakaba |
1.4 |
=cut |
1787 |
wakaba |
1.2 |
|
1788 |
wakaba |
1.10 |
## $Date: 2007/07/07 11:11:34 $ |