comparison _test/Test/DOM/Builder.pm @ 35:f25d021780b3

DOM::Navigator::Builder working version
author Sergey
date Tue, 17 Nov 2009 17:46:24 +0300
parents a8086f85a571
children 1828103371d0
comparison
equal deleted inserted replaced
34:a8086f85a571 35:f25d021780b3
23 $schema->appendRange( 23 $schema->appendRange(
24 IMPL::DOM::Schema::ComplexNode->new( name => 'personInfo' )->appendRange( 24 IMPL::DOM::Schema::ComplexNode->new( name => 'personInfo' )->appendRange(
25 IMPL::DOM::Schema::NodeSet->new()->appendRange( 25 IMPL::DOM::Schema::NodeSet->new()->appendRange(
26 new IMPL::DOM::Schema::SimpleNode( name => 'firstName' ), 26 new IMPL::DOM::Schema::SimpleNode( name => 'firstName' ),
27 new IMPL::DOM::Schema::SimpleNode( name => 'lastName' ), 27 new IMPL::DOM::Schema::SimpleNode( name => 'lastName' ),
28 new IMPL::DOM::Schema::ComplexNode( name => 'address' )->appendRange( 28 new IMPL::DOM::Schema::ComplexNode( name => 'address', maxOccur => 'unbounded' )->appendRange(
29 IMPL::DOM::Schema::NodeSet->new()->appendRange( 29 IMPL::DOM::Schema::NodeSet->new()->appendRange(
30 new IMPL::DOM::Schema::SimpleNode( name => 'street' ), 30 new IMPL::DOM::Schema::SimpleNode( name => 'street' ),
31 new IMPL::DOM::Schema::SimpleNode( name => 'line', minOccur => 0 ) 31 new IMPL::DOM::Schema::SimpleNode( name => 'line', minOccur => 0 )
32 ) 32 )
33 ) 33 )
53 my $builder = IMPL::DOM::Navigator::Builder->new( 53 my $builder = IMPL::DOM::Navigator::Builder->new(
54 'IMPL::DOM::Document', 54 'IMPL::DOM::Document',
55 $this->schemaDoc 55 $this->schemaDoc
56 ); 56 );
57 57
58 use Time::HiRes qw(gettimeofday tv_interval);
59
60 my $t = [gettimeofday];
61
58 $builder->NavigateCreate('personInfo', version => '1'); 62 $builder->NavigateCreate('personInfo', version => '1');
59 $builder->NavigateCreate('firstName')->nodeValue('Nemo'); 63 $builder->NavigateCreate('firstName')->nodeValue('Nemo');
60 $builder->Back(); 64 $builder->Back();
61 $builder->NavigateCreate('address', local => 1); 65 $builder->NavigateCreate('lastName')->nodeValue('Nobel');
62 $builder->NavigateCreate('street')->nodeValue('Hellroad'); 66 $builder->Back();
67 $builder->NavigateCreate('lastName')->nodeValue('Gardum');
68 $builder->Back();
69 for(1..100) {
70 $builder->NavigateCreate('address', local => 1);
71 $builder->NavigateCreate('street')->nodeValue('Hellroad');
72 $builder->Back();
73 $builder->NavigateCreate('line')->nodeValue($_);
74 $builder->Back();
63 $builder->Back(); 75 $builder->Back();
64 $builder->Back(); 76 }
65 $builder->Back(); 77 $builder->Back();
78
79 print "Build: ",tv_interval($t,[gettimeofday]),"\n";
80 $t = [gettimeofday];
81 print $_->Message,"\n" foreach $this->schemaDoc->Validate($builder->Document);
82 print "Validate: ",tv_interval($t,[gettimeofday]),"\n";
66 83
67 return 1; 84 return 1;
68 }; 85 };
69 86
70 87