perl-XML-LibXML / t / 10ns.t

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# -*- cperl -*-

use strict;
use warnings;

# Should be 129.
use Test::More tests => 129;

use XML::LibXML;
use XML::LibXML::Common qw(:libxml);

my $parser = XML::LibXML->new();

my $xml1 = <<EOX;
<a xmlns:b="http://whatever"
><x b:href="out.xml"
/><b:c/></a>
EOX

my $xml2 = <<EOX;
<a xmlns:b="http://whatever" xmlns:c="http://kungfoo"
><x b:href="out.xml"
/><b:c/><c:b/></a>
EOX

my $xml3 = <<EOX;
<a xmlns:b="http://whatever">
    <x b:href="out.xml"/>
    <x>
    <c:b xmlns:c="http://kungfoo">
        <c:d/>
    </c:b>
    </x>
    <x>
    <c:b xmlns:c="http://foobar">
        <c:d/>
    </c:b>
    </x>
</a>
EOX

print "# 1.   single namespace \n";

{
    my $doc1 = $parser->parse_string( $xml1 );
    my $elem = $doc1->documentElement;
    # TEST
    is($elem->lookupNamespaceURI( "b" ), "http://whatever", ' TODO : Add test name' );
    my @cn = $elem->childNodes;
    # TEST
    is($cn[0]->lookupNamespaceURI( "b" ), "http://whatever", ' TODO : Add test name' );
    # TEST
    is($cn[1]->namespaceURI, "http://whatever", ' TODO : Add test name' );
}

print "# 2.    multiple namespaces \n";

{
    my $doc2 = $parser->parse_string( $xml2 );

    my $elem = $doc2->documentElement;
    # TEST
    is($elem->lookupNamespaceURI( "b" ), "http://whatever", ' TODO : Add test name');
    # TEST
    is($elem->lookupNamespaceURI( "c" ), "http://kungfoo", ' TODO : Add test name');
    my @cn = $elem->childNodes;

    # TEST

    is($cn[0]->lookupNamespaceURI( "b" ), "http://whatever", ' TODO : Add test name' );
    # TEST
    is($cn[0]->lookupNamespaceURI( "c" ), "http://kungfoo", ' TODO : Add test name');

    # TEST

    is($cn[1]->namespaceURI, "http://whatever", ' TODO : Add test name' );
    # TEST
    is($cn[2]->namespaceURI, "http://kungfoo", ' TODO : Add test name' );
}

print "# 3.   nested names \n";

{
    my $doc3 = $parser->parse_string( $xml3 );
    my $elem = $doc3->documentElement;
    my @cn = $elem->childNodes;
    my @xs = grep { $_->nodeType == XML_ELEMENT_NODE } @cn;

    my @x1 = $xs[1]->childNodes; my @x2 = $xs[2]->childNodes;

    # TEST

    is( $x1[1]->namespaceURI , "http://kungfoo", ' TODO : Add test name' );
    # TEST
    is( $x2[1]->namespaceURI , "http://foobar", ' TODO : Add test name' );

    # namespace scopeing
    # TEST
    ok( !defined($elem->lookupNamespacePrefix( "http://kungfoo" )), ' TODO : Add test name' );
    # TEST
    ok( !defined($elem->lookupNamespacePrefix( "http://foobar" )), ' TODO : Add test name' );
}

print "# 4. post creation namespace setting\n";
{
    my $e1 = XML::LibXML::Element->new("foo");
    my $e2 = XML::LibXML::Element->new("bar:foo");
    my $e3 = XML::LibXML::Element->new("foo");
    $e3->setAttribute( "kung", "foo" );
    my $a = $e3->getAttributeNode("kung");

    $e1->appendChild($e2);
    $e2->appendChild($e3);
    # TEST
    ok( $e2->setNamespace("http://kungfoo", "bar"), ' TODO : Add test name' );
    # TEST
    ok( $a->setNamespace("http://kungfoo", "bar"), ' TODO : Add test name' );
    # TEST
    is( $a->nodeName, "bar:kung", ' TODO : Add test name' );
}

print "# 5. importing namespaces\n";

{

    my $doca = XML::LibXML->createDocument;
    my $docb = XML::LibXML->new()->parse_string( <<EOX );
<x:a xmlns:x="http://foo.bar"><x:b/></x:a>
EOX

    my $b = $docb->documentElement->firstChild;

    my $c = $doca->importNode( $b );

    my @attra = $c->attributes;
    # TEST
    is( scalar(@attra), 1, ' TODO : Add test name' );
    # TEST
    is( $attra[0]->nodeType, 18, ' TODO : Add test name' );
    my $d = $doca->adoptNode($b);

    # TEST

    ok( $d->isSameNode( $b ), ' TODO : Add test name' );
    my @attrb = $d->attributes;
    # TEST
    is( scalar(@attrb), 1, ' TODO : Add test name' );
    # TEST
    is( $attrb[0]->nodeType, 18, ' TODO : Add test name' );
}

print "# 6. lossless setting of namespaces with setAttribute\n";
# reported by Kurt George Gjerde
{
    my $doc = XML::LibXML->createDocument;
    my $root = $doc->createElementNS('http://example.com', 'document');
    $root->setAttribute('xmlns:xxx', 'http://example.com');
    $root->setAttribute('xmlns:yyy', 'http://yonder.com');
    $doc->setDocumentElement( $root );

    my $strnode = $root->toString();
    # TEST
    ok ( $strnode =~ /xmlns:xxx/ and $strnode =~ /xmlns=/, ' TODO : Add test name' );
}

print "# 7. namespaced attributes\n";
{
    my $doc = XML::LibXML->new->parse_string(<<'EOF');
<test xmlns:xxx="http://example.com"/>
EOF
    my $root = $doc->getDocumentElement();
    # namespaced attributes
    $root->setAttribute('xxx:attr', 'value');
    # TEST
    ok ( $root->getAttributeNode('xxx:attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xxx:attr'), 'value', ' TODO : Add test name' );
    print $root->toString(1),"\n";
    # TEST
    ok ( $root->getAttributeNodeNS('http://example.com','attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNS('http://example.com','attr'), 'value', ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNode('xxx:attr')->getNamespaceURI(), 'http://example.com', ' TODO : Add test name');

    #change encoding to UTF-8 and retest
    $doc->setEncoding('UTF-8');
    # namespaced attributes
    $root->setAttribute('xxx:attr', 'value');
    # TEST
    ok ( $root->getAttributeNode('xxx:attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xxx:attr'), 'value', ' TODO : Add test name' );
    print $root->toString(1),"\n";
    # TEST
    ok ( $root->getAttributeNodeNS('http://example.com','attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNS('http://example.com','attr'), 'value', ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNode('xxx:attr')->getNamespaceURI(), 
        'http://example.com', ' TODO : Add test name');
}

print "# 8. changing namespace declarations\n";
{
    my $xmlns = 'http://www.w3.org/2000/xmlns/';

    my $doc = XML::LibXML->createDocument;
    my $root = $doc->createElementNS('http://example.com', 'document');
    $root->setAttributeNS($xmlns, 'xmlns:xxx', 'http://example.com');
    $root->setAttribute('xmlns:yyy', 'http://yonder.com');
    $doc->setDocumentElement( $root );

    # can we get the namespaces ?
    # TEST
    is ( $root->getAttribute('xmlns:xxx'), 'http://example.com', ' TODO : Add test name');
    # TEST
    is ( $root->getAttributeNS($xmlns,'xmlns'), 'http://example.com', ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xmlns:yyy'), 'http://yonder.com', ' TODO : Add test name');
    # TEST
    is ( $root->lookupNamespacePrefix('http://yonder.com'), 'yyy', ' TODO : Add test name');
    # TEST
    is ( $root->lookupNamespaceURI('yyy'), 'http://yonder.com', ' TODO : Add test name');

    # can we change the namespaces ?
    # TEST
    ok ( $root->setAttribute('xmlns:yyy', 'http://newyonder.com'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xmlns:yyy'), 'http://newyonder.com', ' TODO : Add test name');
    # TEST
    is ( $root->lookupNamespacePrefix('http://newyonder.com'), 'yyy', ' TODO : Add test name');
    # TEST
    is ( $root->lookupNamespaceURI('yyy'), 'http://newyonder.com', ' TODO : Add test name');

    # can we change the default namespace ?
    $root->setAttribute('xmlns', 'http://other.com' );
    # TEST
    is ( $root->getAttribute('xmlns'), 'http://other.com', ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespacePrefix('http://other.com'), "", ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(''), 'http://other.com', ' TODO : Add test name' );

    # non-existent namespaces
    # TEST
    is ( $root->lookupNamespaceURI('foo'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespacePrefix('foo'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xmlns:foo'), undef, ' TODO : Add test name' );

    # changing namespace declaration URI and prefix
    # TEST
    ok ( $root->setNamespaceDeclURI('yyy', 'http://changed.com'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xmlns:yyy'), 'http://changed.com', ' TODO : Add test name');
    # TEST
    is ( $root->lookupNamespaceURI('yyy'), 'http://changed.com', ' TODO : Add test name');
    eval { $root->setNamespaceDeclPrefix('yyy','xxx'); };
    # TEST
    ok ( $@, ' TODO : Add test name' );  # prefix occupied
    eval { $root->setNamespaceDeclPrefix('yyy',''); };
    # TEST
    ok ( $@, ' TODO : Add test name' );  # prefix occupied
    # TEST
    ok ( $root->setNamespaceDeclPrefix('yyy', 'zzz'), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('yyy'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('zzz'), 'http://changed.com', ' TODO : Add test name' );
    # TEST
    ok ( $root->setNamespaceDeclURI('zzz',undef ), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('zzz'), undef, ' TODO : Add test name' );

    my $strnode = $root->toString();
    # TEST
    ok ( $strnode !~ /xmlns:zzz/, ' TODO : Add test name' );

    # changing the default namespace declaration
    # TEST
    ok ( $root->setNamespaceDeclURI('','http://test'), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(''), 'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->getNamespaceURI(), 'http://test', ' TODO : Add test name' );

    # changing prefix of the default ns declaration
    # TEST
    ok ( $root->setNamespaceDeclPrefix('','foo'), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(''), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('foo'), 'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->getNamespaceURI(),  'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->prefix(),  'foo', ' TODO : Add test name' );

    # turning a ns declaration to a default ns declaration
    # TEST
    ok ( $root->setNamespaceDeclPrefix('foo',''), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('foo'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(''), 'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(undef), 'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->getNamespaceURI(),  'http://test', ' TODO : Add test name' );
    # TEST
    is ( $root->prefix(),  undef, ' TODO : Add test name' );

    # removing the default ns declaration
    # TEST
    ok ( $root->setNamespaceDeclURI('',undef), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI(''), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->getNamespaceURI(), undef, ' TODO : Add test name' );

    $strnode = $root->toString();
    # TEST
    ok ( $strnode !~ /xmlns=/, ' TODO : Add test name' );

    # namespaced attributes
    $root->setAttribute('xxx:attr', 'value');
    # TEST
    ok ( $root->getAttributeNode('xxx:attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('xxx:attr'), 'value', ' TODO : Add test name' );
    print $root->toString(1),"\n";
    # TEST
    ok ( $root->getAttributeNodeNS('http://example.com','attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNS('http://example.com','attr'), 'value', ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNode('xxx:attr')->getNamespaceURI(), 'http://example.com', ' TODO : Add test name');

    # removing other xmlns declarations
    $root->addNewChild('http://example.com', 'xxx:foo');
    # TEST
    ok( $root->setNamespaceDeclURI('xxx',undef), ' TODO : Add test name' );
    # TEST
    is ( $root->lookupNamespaceURI('xxx'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->getNamespaceURI(), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->firstChild->getNamespaceURI(), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->prefix(),  undef, ' TODO : Add test name' );
    # TEST
    is ( $root->firstChild->prefix(),  undef, ' TODO : Add test name' );


    print $root->toString(1),"\n";
    # check namespaced attributes
    # TEST
    is ( $root->getAttributeNode('xxx:attr'), undef, ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNodeNS('http://example.com', 'attr'), undef, ' TODO : Add test name' );
    # TEST
    ok ( $root->getAttributeNode('attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttribute('attr'), 'value', ' TODO : Add test name' );
    # TEST
    ok ( $root->getAttributeNodeNS(undef,'attr'), ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNS(undef,'attr'), 'value', ' TODO : Add test name' );
    # TEST
    is ( $root->getAttributeNode('attr')->getNamespaceURI(), undef, ' TODO : Add test name');


    $strnode = $root->toString();
    # TEST
    ok ( $strnode !~ /xmlns=/, ' TODO : Add test name' );
    # TEST
    ok ( $strnode !~ /xmlns:xxx=/, ' TODO : Add test name' );
    # TEST
    ok ( $strnode =~ /<foo/, ' TODO : Add test name' );

    # TEST

    ok ( $root->setNamespaceDeclPrefix('xxx',undef), ' TODO : Add test name' );

    # TEST

    is ( $doc->findnodes('/document/foo')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $doc->findnodes('/document[foo]')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $doc->findnodes('/document[*]')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $doc->findnodes('/document[@attr and foo]')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $doc->findvalue('/document/@attr'), 'value', ' TODO : Add test name' );

    my $xp = XML::LibXML::XPathContext->new($doc);
    # TEST
    is ( $xp->findnodes('/document/foo')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $xp->findnodes('/document[foo]')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $xp->findnodes('/document[*]')->size(), 1, ' TODO : Add test name' );

    # TEST

    is ( $xp->findnodes('/document[@attr and foo]')->size(), 1, ' TODO : Add test name' );
    # TEST
    is ( $xp->findvalue('/document/@attr'), 'value', ' TODO : Add test name' );

    # TEST

    is ( $root->firstChild->prefix(),  undef, ' TODO : Add test name' );
}

print "# 9. namespace reconciliation\n";
{
    my $doc = XML::LibXML->createDocument( 'http://default', 'root' );
    my $root = $doc->documentElement;
    $root->setNamespace( 'http://children', 'child', 0 );

    $root->appendChild( my $n = $doc->createElementNS( 'http://default', 'branch' ));
    # appending an element in the same namespace will
    # strip its declaration
    # TEST
    ok( !defined($n->getAttribute( 'xmlns' )), ' TODO : Add test name' );

    $n->appendChild( my $a = $doc->createElementNS( 'http://children', 'child:a' ));
    $n->appendChild( my $b = $doc->createElementNS( 'http://children', 'child:b' ));

    $n->appendChild( my $c = $doc->createElementNS( 'http://children', 'child:c' ));
    # appending $c strips the declaration
    # TEST
    ok( !defined($c->getAttribute('xmlns:child')), ' TODO : Add test name' );

    # add another prefix for children
    $c->setAttribute( 'xmlns:foo', 'http://children' );
    # TEST
    is( $c->getAttribute( 'xmlns:foo' ), 'http://children', ' TODO : Add test name' );

    $n->appendChild( my $d = $doc->createElementNS( 'http://other', 'branch' ));
    # appending an element with a new default namespace
    # will leave it declared
    # TEST
    is( $d->getAttribute( 'xmlns' ), 'http://other', ' TODO : Add test name' );

    my $doca = XML::LibXML->createDocument( 'http://default/', 'root' );
    $doca->adoptNode( $a );
    $doca->adoptNode( $b );
    $doca->documentElement->appendChild( $a );
    $doca->documentElement->appendChild( $b );

    # Because the child namespace isn't defined in $doca
    # it should get declared on both child nodes $a and $b
    # TEST
    is( $a->getAttribute( 'xmlns:child' ), 'http://children', ' TODO : Add test name' );
    # TEST
    is( $b->getAttribute( 'xmlns:child' ), 'http://children', ' TODO : Add test name' );

    $doca = XML::LibXML->createDocument( 'http://children', 'child:root' );
    $doca->adoptNode( $a );
    $doca->documentElement->appendChild( $a );

    # $doca declares the child namespace, so the declaration
    # should now get stripped from $a
    # TEST
    ok( !defined($a->getAttribute( 'xmlns:child' )), ' TODO : Add test name' );

    $doca->documentElement->removeChild( $a );

    # $a should now have its namespace re-declared
    # TEST
    is( $a->getAttribute( 'xmlns:child' ), 'http://children', ' TODO : Add test name' );

    $doca->documentElement->appendChild( $a );

    # $doca declares the child namespace, so the declaration
    # should now get stripped from $a
    # TEST
    ok( !defined($a->getAttribute( 'xmlns:child' )), ' TODO : Add test name' );


    $doc = XML::LibXML::Document->new;
    $n = $doc->createElement( 'didl' );
    $n->setAttribute( "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance" );

    $a = $doc->createElement( 'dc' );
    $a->setAttribute( "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance" );
    $a->setAttribute( "xsi:schemaLocation"=>"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives
.org/OAI/2.0/oai_dc.xsd" );

    $n->appendChild( $a );

    # the declaration for xsi should be stripped
    # TEST
    ok( !defined($a->getAttribute( 'xmlns:xsi' )), ' TODO : Add test name' );

    $n->removeChild( $a );

    # should be a new declaration for xsi in $a
    # TEST
    is( $a->getAttribute( 'xmlns:xsi' ), 'http://www.w3.org/2001/XMLSchema-instance', ' TODO : Add test name' );

    $b = $doc->createElement( 'foo' );
    $b->setAttribute( 'xsi:bar', 'bar' );
    $n->appendChild( $b );
    $n->removeChild( $b );

    # a prefix without a namespace can't be reliably compared,
    # so $b doesn't acquire a declaration from $n!
    # TEST
    ok( !defined($b->getAttribute( 'xmlns:xsi' )), ' TODO : Add test name' );

    # tests for reconciliation during setAttributeNodeNS
    my $attr = $doca->createAttributeNS(
        'http://children', 'child:attr','value'
    );
    # TEST
    ok($attr, ' TODO : Add test name');
    my $child= $doca->documentElement->firstChild;
    # TEST
    ok($child, ' TODO : Add test name');
    $child->setAttributeNodeNS($attr);
    # TEST
    ok ( !defined($child->getAttribute( 'xmlns:child' )), ' TODO : Add test name' );

    # due to libxml2 limitation, XML::LibXML declares the namespace
    # on the root element
    $attr = $doca->createAttributeNS('http://other','other:attr','value');
    # TEST
    ok($attr, ' TODO : Add test name');
    $child->setAttributeNodeNS($attr);
    #
    # TEST
    ok ( !defined($child->getAttribute( 'xmlns:other' )), ' TODO : Add test name' );
    # TEST
    ok ( defined($doca->documentElement->getAttribute( 'xmlns:other' )), ' TODO : Add test name' );
}

print "# 10. xml namespace\n";
{
    my $docOne = XML::LibXML->new->parse_string(
        '<foo><inc xml:id="test"/></foo>'
    );
    my $docTwo = XML::LibXML->new->parse_string(
        '<bar><urgh xml:id="foo"/></bar>'
    );

    my $inc = $docOne->getElementById('test');
    my $rep = $docTwo->getElementById('foo');
    $inc->parentNode->replaceChild($rep, $inc);
    # TEST
    is($inc->getAttributeNS('http://www.w3.org/XML/1998/namespace','id'),'test', ' TODO : Add test name');
    # TEST
    ok($inc->isSameNode($docOne->getElementById('test')), ' TODO : Add test name');
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.