/[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

Diff of /google/rules.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by dpavlin, Sun Jun 17 21:58:57 2007 UTC revision 24 by dpavlin, Sun Jun 17 22:14:59 2007 UTC
# Line 16  my $parser = XML::Rules->new( Line 16  my $parser = XML::Rules->new(
16  #               '^division_name,fax' => 'skip',  #               '^division_name,fax' => 'skip',
17  #       ],  #       ],
18          namespaces => {          namespaces => {
19                  'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv',  #               'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv',
20                  'http://schemas.xmlsoap.org/soap/encoding/' => 'soap',  #               'http://schemas.xmlsoap.org/soap/encoding/' => 'soap',
21                  'urn:dslforum-org:cwmp-1-0' => 'cwmp',                  'urn:dslforum-org:cwmp-1-0' => '',
22          },          },
23          rules => [          rules => [
24                  #_default => 'content trim',                  #_default => 'content trim',
# Line 28  my $parser = XML::Rules->new( Line 28  my $parser = XML::Rules->new(
28                  },                  },
29                  qr/DeviceId/ => sub {                  qr/DeviceId/ => sub {
30                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
31                          $state->{ $tag_name } = $tag_hash;                          foreach my $name ( keys %$tag_hash ) {
32                                    next if $name eq '_content';
33                                    my $key = $name;
34                                    $key =~ s/^\w+://;      # stip namespace
35                                    $state->{DeviceID}->{ $key } = $tag_hash->{$name}->{_content};
36                            }
37                  },                  },
38                  EventStruct => sub {                  qr/EventStruct/ => sub {
39                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
40                          push @{ $state->{ $tag_name } }, $tag_hash->{EventCode}->{_content};                          warn dump( $tag_name, $tag_hash );
41                            push @{ $state->{EventStruct} }, $tag_hash->{EventCode}->{_content};
42                  },                  },
43                  MaxEnvelopes => sub {                  qr/MaxEnvelopes/ => sub {
44                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;                          my ($tag_name, $tag_hash, $context, $parent_data) = @_;
45                          $state->{ $tag_name } = $tag_hash->{_content};                          $state->{MaxEnvelopes} = $tag_hash->{_content};
46                  }                  }
47          ]          ]
48  );  );
# Line 44  my $parser = XML::Rules->new( Line 50  my $parser = XML::Rules->new(
50  my $xml = read_file( $path );  my $xml = read_file( $path );
51  print "## $1 ##\n" if ( $xml =~ s/^Name:\s+(.*?)$//sm );  print "## $1 ##\n" if ( $xml =~ s/^Name:\s+(.*?)$//sm );
52  $xml =~ s/^.*Response:\s+//sm;  $xml =~ s/^.*Response:\s+//sm;
53  warn $xml;  #warn $xml;
54  $parser->parsestring( $xml );  $parser->parsestring( $xml );
55    
56  print "state = ", dump( $state );  print "state = ", dump( $state );

Legend:
Removed from v.23  
changed lines
  Added in v.24

  ViewVC Help
Powered by ViewVC 1.1.26