# HG changeset patch # User Sergey # Date 1251462380 -14400 # Node ID 63f6653b094e29118f68d0c0013f69d49c6f5437 # Parent 5899df8c289efc559749e3c7f6fe0bd64033ffcd DOM diff -r 5899df8c289e -r 63f6653b094e Lib/IMPL/DOM/XMLReader.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/DOM/XMLReader.pm Fri Aug 28 16:26:20 2009 +0400 @@ -0,0 +1,47 @@ +package IMPL::DOM::XMLReader; +use strict; +use warnings; + +use base qw(IMPL::Object IMPL::Object::Autofill); +use IMPL::Class::Property; +use IMPL::Class::Property::Direct; +use XML::Parser; + +BEGIN { + public _direct property Navigator => prop_get | owner_set; + private _direct property _current => prop_all; +} + +sub Parse { + 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->parse($in); +} + +sub OnBegin { + my ($this,$element,%attrs) = @_; + + $this->{$_current} = $this->Navigator->CreateAndNavigate($element,%attrs); +} + +sub OnEnd { + my ($this,$element) = @_; + + $this->{$_current} = $this->Back; +} + +sub OnChar { + my ($this,$val) = @_; + + $this->{$_current}->nodeValue($this->{$_current}->nodeValue . $val); +} + +1; diff -r 5899df8c289e -r 63f6653b094e _test/Resources/form.schema --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_test/Resources/form.schema Fri Aug 28 16:26:20 2009 +0400 @@ -0,0 +1,29 @@ + + + +
+ + + \w{4,10} + + + +
+ diff -r 5899df8c289e -r 63f6653b094e _test/Resources/test.schema --- a/_test/Resources/test.schema Thu Aug 27 17:49:42 2009 +0400 +++ b/_test/Resources/test.schema Fri Aug 28 16:26:20 2009 +0400 @@ -1,12 +1,8 @@ + - - - - - - + @@ -15,13 +11,13 @@ \w+ - - + + - - - - + + + + diff -r 5899df8c289e -r 63f6653b094e _test/any.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_test/any.t Fri Aug 28 16:26:20 2009 +0400 @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +#use strict; + +use HTML::Element; +$a = HTML::Element->new('a', href => 'http://www.perl.com/'); +$a->push_content("The Perl Homepage"); + +$tag = $a->tag; +print "$tag starts out as:", $a->starttag, "\n"; +print "$tag ends as:", $a->endtag, "\n"; +print "$tag\'s href attribute is: ", $a->attr('href'), "\n"; + +$links_r = $a->extract_links(); +print "Hey, I found ", scalar(@$links_r), " links.\n"; + +print "And that, as HTML, is: ", $a->as_HTML, "\n"; +$a = $a->delete; + + diff -r 5899df8c289e -r 63f6653b094e impl.kpf --- a/impl.kpf Thu Aug 27 17:49:42 2009 +0400 +++ b/impl.kpf Fri Aug 28 16:26:20 2009 +0400 @@ -196,6 +196,32 @@ default + + + + + + 9011 + + + _test/any.t + + Perl + + + + application/x-www-form-urlencoded + GET + 1 + 0 + 0 + + + enabled + + + default +