Mercurial > pub > Impl
changeset 12:955b2324c1bf
Работа над навигаторами и схемой DOM модели
author | Sergey |
---|---|
date | Mon, 31 Aug 2009 01:37:43 +0400 |
parents | 63f6653b094e |
children | bb8d67f811ea |
files | Lib/IMPL/DOM/Navigator.pm Lib/IMPL/DOM/Navigator/Builder.pm Lib/IMPL/DOM/XMLReader.pm _test/Resources/test.schema impl.kpf |
diffstat | 5 files changed, 127 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator.pm Fri Aug 28 16:26:20 2009 +0400 +++ b/Lib/IMPL/DOM/Navigator.pm Mon Aug 31 01:37:43 2009 +0400 @@ -2,9 +2,7 @@ use strict; use warnings; -require Exporter; -our @ISA = qw(Exporter); -our @EXPORT_OK = qw(); +use base qw(IMPL::Object);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/DOM/Navigator/Builder.pm Mon Aug 31 01:37:43 2009 +0400 @@ -0,0 +1,38 @@ +package IMPL::DOM::Navigator::Builder; +use strict; +use warnings; + +use base qw(IMPL::DOM::Navigator); + +use IMPL::Class::Property; + +BEGIN { + public property SchemaNavigator => prop_get | owner_set; +} + +1; + +=pod + +=head1 SYNOPSIS + +my $nav = new IMPL::DOM::Navigator::Builder(Schema => $mySchema); + +# set position to root +$nav->InitRoot(); + +# go to node 'Person' and create one if not exists +$nav->NavigateAuto("Person"); + +# set some node properties +$nav->nodeCurrent->Name("Smith"); +$nav->nodeCurrent->Age("20"); + +# navigate to node 'Address' and create one if not exists +$nav->NavigateAuto("Address"); + +=head1 DESCRIPTION + +, + +=cut \ No newline at end of file
--- a/Lib/IMPL/DOM/XMLReader.pm Fri Aug 28 16:26:20 2009 +0400 +++ b/Lib/IMPL/DOM/XMLReader.pm Mon Aug 31 01:37:43 2009 +0400 @@ -26,10 +26,25 @@ $parser->parse($in); } +sub ParseFile { + my ($this,$in) = @_; + + my $parser = new XML::Parser( + Handlers => { + Start => sub {shift; goto &OnStart($this,@_)}, + End => sub {shift; goto &OnEnd($this,@_)}, + Char => sub {shift; goto &OnChar($this,@_)} + } + ); + + $parser->parsefile($in); +} + + sub OnBegin { my ($this,$element,%attrs) = @_; - $this->{$_current} = $this->Navigator->CreateAndNavigate($element,%attrs); + $this->{$_current} = $this->Navigator->NavigateCreate($element,%attrs); } sub OnEnd { @@ -45,3 +60,21 @@ } 1; + +__END__ + +=pod + +=head1 SYNOPSIS + +my $reader = new IMPL::DOM::XMLReader(Navigator => $DomBuilder); +my $obj = $reader->parsefile("data.xml"); + +=head2 DESCRIPTION + + , . + . + + C<NavigateCreate> C<Back> + +=cut
--- a/_test/Resources/test.schema Fri Aug 28 16:26:20 2009 +0400 +++ b/_test/Resources/test.schema Mon Aug 31 01:37:43 2009 +0400 @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <schema> + <!-- Директивы --> <!-- Загрузка фрагмента схемы --> <Include src="basic.types.schema"/> + <!-- Содержимое возможные варианты для документов--> <ComplexNode nodeName="Form"> <NodeSet> <SimpleNode nodeName="FirstName">
--- a/impl.kpf Fri Aug 28 16:26:20 2009 +0400 +++ b/impl.kpf Mon Aug 31 01:37:43 2009 +0400 @@ -118,6 +118,32 @@ </preference-set> </preference-set> </preference-set> +<preference-set idref="66c7d414-175f-45b6-92fe-dbda51c64843/Lib/IMPL/DOM/Navigator/Builder.pm"> +<preference-set id="Invocations"> +<preference-set id="default"> + <string id="cookieparams"></string> + <string id="cwd"></string> + <long id="debugger.io-port">9011</long> + <string id="documentRoot"></string> + <string id="executable-params"></string> + <string relative="path" id="filename">Lib/IMPL/DOM/Navigator/Builder.pm</string> + <string id="getparams"></string> + <string id="language">Perl</string> + <string id="mpostparams"></string> + <string id="params"></string> + <string id="postparams"></string> + <string id="posttype">application/x-www-form-urlencoded</string> + <string id="request-method">GET</string> + <boolean id="show-dialog">1</boolean> + <boolean id="sim-cgi">0</boolean> + <boolean id="use-console">0</boolean> + <string id="userCGIEnvironment"></string> + <string id="userEnvironment"></string> + <string id="warnings">enabled</string> +</preference-set> +</preference-set> + <string id="lastInvocation">default</string> +</preference-set> <preference-set idref="66c7d414-175f-45b6-92fe-dbda51c64843/Lib/IMPL/DOM/Schema/Item.pm"> <preference-set id="Invocations"> <preference-set id="default"> @@ -144,6 +170,32 @@ </preference-set> <string id="lastInvocation">default</string> </preference-set> +<preference-set idref="66c7d414-175f-45b6-92fe-dbda51c64843/Lib/IMPL/DOM/XMLReader.pm"> +<preference-set id="Invocations"> +<preference-set id="default"> + <string id="cookieparams"></string> + <string id="cwd"></string> + <long id="debugger.io-port">9011</long> + <string id="documentRoot"></string> + <string id="executable-params"></string> + <string relative="path" id="filename">Lib/IMPL/DOM/XMLReader.pm</string> + <string id="getparams"></string> + <string id="language">Perl</string> + <string id="mpostparams"></string> + <string id="params"></string> + <string id="postparams"></string> + <string id="posttype">application/x-www-form-urlencoded</string> + <string id="request-method">GET</string> + <boolean id="show-dialog">1</boolean> + <boolean id="sim-cgi">0</boolean> + <boolean id="use-console">0</boolean> + <string id="userCGIEnvironment"></string> + <string id="userEnvironment"></string> + <string id="warnings">enabled</string> +</preference-set> +</preference-set> + <string id="lastInvocation">default</string> +</preference-set> <preference-set idref="66c7d414-175f-45b6-92fe-dbda51c64843/Lib/IMPL/Object.pm"> <preference-set id="Invocations"> <preference-set id="default">