File: 01basics.t

package info (click to toggle)
libxml-libxml-debugging-perl 0.103-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 204; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download | duplicates (6)
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
use Test::More tests => 3;
BEGIN { use_ok('XML::LibXML::Debugging') };

use XML::LibXML;

my $doc  = XML::LibXML::Document->new;
my $root = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'html');
$doc->setDocumentElement($root);
$root->setAttribute('xml:lang', 'en-gb-oed');

is(
	$doc->toClarkML,
	'<{http://www.w3.org/1999/xhtml}html {http://www.w3.org/XML/1998/namespace}lang="en-gb-oed" {http://www.w3.org/2000/xmlns/}xmlns="http://www.w3.org/1999/xhtml"/>',
	"toClarkML seems to be working.");

my $correct = {
          'root' => {
                      'nsuri' => 'http://www.w3.org/1999/xhtml',
                      'suffix' => 'html',
                      'qname' => 'html',
                      'children' => [],
                      'type' => 'Element',
                      'attributes' => [
                                        {
                                          'value' => 'en-gb-oed',
                                          'nsuri' => 'http://www.w3.org/XML/1998/namespace',
                                          'suffix' => 'lang',
                                          'qname' => 'xml:lang',
                                          'type' => 'Attribute',
                                          'prefix' => 'xml'
                                        },
                                        {
                                          'value' => 'http://www.w3.org/1999/xhtml',
                                          'nsuri' => 'http://www.w3.org/2000/xmlns/',
                                          'suffix' => undef,
                                          'qname' => 'xmlns',
                                          'type' => 'Namespace Declaration',
                                          'prefix' => 'xmlns'
                                        }
                                      ],
                      'prefix' => undef
                    },
          'type' => 'Document'
        };

is_deeply($doc->toDebuggingHash, $correct, "toDebuggingHash seems to work.");