diff -r 3f8d2ea13886 -r 1d9c60a4e308 common/tools/raptor/RaptorSAXHandler.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/tools/raptor/RaptorSAXHandler.pm Tue Jun 30 13:58:29 2009 +0100 @@ -0,0 +1,93 @@ +# Copyright (c) 2009 Symbian Foundation Ltd +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Symbian Foundation Ltd - initial contribution. +# +# Contributors: +# +# Description: +# SAX Handler for the Raptor log + +package RaptorSAXHandler; +use base qw(XML::SAX::Base); + +sub new +{ + my ($type) = @_; + + return bless {}, $type; +} + +sub set_init_status +{ + my ($self, $initialstatus) = @_; + + $self->{status} = $initialstatus; +} + +sub start_document +{ + my ($self, $doc) = @_; + # process document start event + + #print "start_document\n"; +} + +sub start_element +{ + my ($self, $el) = @_; + # process element start event + + my $tagname = $el->{LocalName}; + + #print "start_element($tagname)\n"; + + + if (defined $self->{status}->{next_status}->{$tagname}) + { + my $oldstatus = $self->{status}; + $self->{status} = $self->{status}->{next_status}->{$tagname}; + #print "status is now $self->{status}->{name}\n"; + $self->{status}->{next_status}->{$tagname} = $oldstatus; + &{$self->{status}->{on_start}}($el) if (defined $self->{status}->{on_start}); + } + elsif (defined $self->{status}->{next_status}->{'?default?'}) + { + #print "changing to default status\n"; + my $oldstatus = $self->{status}; + $self->{status} = $self->{status}->{next_status}->{'?default?'}; + #print "status is now ?default?\n"; + $self->{status}->{next_status}->{$tagname} = $oldstatus; + &{$self->{status}->{on_start}}($el) if (defined $self->{status}->{on_start}); + } +} + +sub end_element +{ + my ($self, $el) = @_; + # process element start event + + my $tagname = $el->{LocalName}; + + #print "end_element($tagname)\n"; + + if (defined $self->{status}->{next_status}->{$tagname}) + { + &{$self->{status}->{on_end}}($el) if (defined $self->{status}->{on_end}); + $self->{status} = $self->{status}->{next_status}->{$tagname}; + #print "status is now $self->{status}->{name}\n"; + } +} + +sub characters +{ + my ($self, $ch) = @_; + + &{$self->{status}->{on_chars}}($ch) if (defined $self->{status}->{on_chars}); +} + +1;