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