/[cwmp]/google/rules.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /google/rules.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Sun Jun 17 21:58:57 2007 UTC (16 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1229 byte(s)
start to work on new XML::Rules based parser for SOAP messages
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use XML::Rules;
7 use File::Slurp;
8 use Data::Dump qw/dump/;
9
10 my $path = $ARGV[0] || 'protocol/inform.xml';
11
12 my $state;
13
14 my $parser = XML::Rules->new(
15 # start_rules => [
16 # '^division_name,fax' => 'skip',
17 # ],
18 namespaces => {
19 'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv',
20 'http://schemas.xmlsoap.org/soap/encoding/' => 'soap',
21 'urn:dslforum-org:cwmp-1-0' => 'cwmp',
22 },
23 rules => [
24 #_default => 'content trim',
25 x_default => sub {
26 my ($tag_name, $tag_hash, $context, $parent_data) = @_;
27 warn dump( $tag_name, $tag_hash, $context );
28 },
29 qr/DeviceId/ => sub {
30 my ($tag_name, $tag_hash, $context, $parent_data) = @_;
31 $state->{ $tag_name } = $tag_hash;
32 },
33 EventStruct => sub {
34 my ($tag_name, $tag_hash, $context, $parent_data) = @_;
35 push @{ $state->{ $tag_name } }, $tag_hash->{EventCode}->{_content};
36 },
37 MaxEnvelopes => sub {
38 my ($tag_name, $tag_hash, $context, $parent_data) = @_;
39 $state->{ $tag_name } = $tag_hash->{_content};
40 }
41 ]
42 );
43
44 my $xml = read_file( $path );
45 print "## $1 ##\n" if ( $xml =~ s/^Name:\s+(.*?)$//sm );
46 $xml =~ s/^.*Response:\s+//sm;
47 warn $xml;
48 $parser->parsestring( $xml );
49
50 print "state = ", dump( $state );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26