comparison Lib/IMPL/DOM/XMLReader.pm @ 14:65a7bb156fb7

Дом модель и схема
author Sergey
date Fri, 04 Sep 2009 16:38:15 +0400
parents bb8d67f811ea
children c2e7f7c96bcd
comparison
equal deleted inserted replaced
13:bb8d67f811ea 14:65a7bb156fb7
4 4
5 use base qw(IMPL::Object IMPL::Object::Autofill); 5 use base qw(IMPL::Object IMPL::Object::Autofill);
6 use IMPL::Class::Property; 6 use IMPL::Class::Property;
7 use IMPL::Class::Property::Direct; 7 use IMPL::Class::Property::Direct;
8 use XML::Parser; 8 use XML::Parser;
9
10 __PACKAGE__->PassThroughArgs;
9 11
10 BEGIN { 12 BEGIN {
11 public _direct property Navigator => prop_get | owner_set; 13 public _direct property Navigator => prop_get | owner_set;
12 private _direct property _current => prop_all; 14 private _direct property _current => prop_all;
13 } 15 }
29 sub ParseFile { 31 sub ParseFile {
30 my ($this,$in) = @_; 32 my ($this,$in) = @_;
31 33
32 my $parser = new XML::Parser( 34 my $parser = new XML::Parser(
33 Handlers => { 35 Handlers => {
34 Start => sub {shift; goto &OnStart($this,@_)}, 36 Start => sub {shift; goto &_OnStart($this,@_)},
35 End => sub {shift; goto &OnEnd($this,@_)}, 37 End => sub {shift; goto &_OnEnd($this,@_)},
36 Char => sub {shift; goto &OnChar($this,@_)} 38 Char => sub {shift; goto &_OnChar($this,@_)}
37 } 39 }
38 ); 40 );
39 41
40 $parser->parsefile($in); 42 $parser->parsefile($in);
41 } 43 }
42 44
43 45
44 sub OnBegin { 46 sub _OnBegin {
45 my ($this,$element,%attrs) = @_; 47 my ($this,$element,%attrs) = @_;
46 48
47 $this->{$_current} = $this->Navigator->NavigateCreate($element,%attrs); 49 $this->{$_current} = $this->Navigator->NavigateCreate($element,%attrs);
48 } 50 }
49 51
50 sub OnEnd { 52 sub _OnEnd {
51 my ($this,$element) = @_; 53 my ($this,$element) = @_;
52 54
53 $this->{$_current} = $this->Back; 55 $this->{$_current} = $this->Back;
54 } 56 }
55 57
56 sub OnChar { 58 sub _OnChar {
57 my ($this,$val) = @_; 59 my ($this,$val) = @_;
58 60
59 $this->{$_current}->nodeValue($this->{$_current}->nodeValue . $val); 61 $this->{$_current}->nodeValue($this->{$_current}->nodeValue . $val);
60 } 62 }
61 63
68 =head1 SYNOPSIS 70 =head1 SYNOPSIS
69 71
70 my $reader = new IMPL::DOM::XMLReader(Navigator => $DomBuilder); 72 my $reader = new IMPL::DOM::XMLReader(Navigator => $DomBuilder);
71 my $obj = $reader->parsefile("data.xml"); 73 my $obj = $reader->parsefile("data.xml");
72 74
73 =head2 DESCRIPTION 75 =head1 DESCRIPTION
74 76
75 , . 77 , .
76 . 78 .
77 79
78 C<NavigateCreate> C<Back> 80 C<NavigateCreate> C<Back>
79 81
82 =head1 METHODS
83
84 =over
85
86 =item C<CTOR(Naviagtor => $builder)>
87
88 ,
89
90 =item C<$obj->Parse($in)>
91
92 . xml , HANDLE.
93
94 =item C<$obj->ParseFile($fileName)>
95
96 C<$fileName>.
97
98 =back
99
80 =cut 100 =cut