comparison Lib/IMPL/DOM/XMLReader.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children 0f59b2de72af
comparison
equal deleted inserted replaced
193:8e8401c0aea4 194:4d0e1962161c
67 my ($this,$val) = @_; 67 my ($this,$val) = @_;
68 $this->{$_text} .= $val; 68 $this->{$_text} .= $val;
69 } 69 }
70 70
71 sub LoadDocument { 71 sub LoadDocument {
72 my ($self,$file,$schema) = @_; 72 my ($self,$file,$schema) = @_;
73 73
74 my $parser; 74 my $parser;
75 if ($schema) { 75 if ($schema) {
76 $schema = IMPL::DOM::Schema->LoadSchema($schema) if not ref $schema; 76 $schema = IMPL::DOM::Schema->LoadSchema($schema) if not ref $schema;
77 $parser = $self->new( 77 $parser = $self->new(
78 Navigator => IMPL::DOM::Navigator::Builder->new( 78 Navigator => IMPL::DOM::Navigator::Builder->new(
79 'IMPL::DOM::Document', 79 'IMPL::DOM::Document',
80 $schema 80 $schema
81 ) 81 )
82 ); 82 );
83 } else { 83 } else {
84 $parser = $self->new( 84 $parser = $self->new(
85 Navigator => IMPL::DOM::Navigator::SimpleBuilder->new() 85 Navigator => IMPL::DOM::Navigator::SimpleBuilder->new()
86 ); 86 );
87 } 87 }
88 88
89 $parser->ParseFile($file); 89 $parser->ParseFile($file);
90 my $doc = $parser->Navigator->Document; 90 my $doc = $parser->Navigator->Document;
91 if ($schema) { 91 if ($schema) {
92 my @errors = $parser->Navigator->BuildErrors; 92 my @errors = $parser->Navigator->BuildErrors;
93 push @errors, $schema->Validate($doc); 93 push @errors, $schema->Validate($doc);
94 die new IMPL::Exception("Loaded document doesn't match the schema", @errors) if @errors; 94 die new IMPL::Exception("Loaded document doesn't match the schema", @errors) if @errors;
95 } 95 }
96 return $doc; 96 return $doc;
97 } 97 }
98 98
99 1; 99 1;
100 100
101 __END__ 101 __END__