#! /usr/bin/perl

use strict;
use warnings;
package XML::TemplateSAX::Cleaner;
use base qw(XML::SAX::Base);

sub start_element {
	my ($self, $data) = @_;
	return if ($data->{'NamespaceURI'} eq 'http://template.sesse.net/');

	# we need to make a copy here, or we'll confuse the upper layers.
	$data = { %$data };
	my $attrs = $data->{'Attributes'} = { %{$data->{'Attributes'}} };
	
	for my $a (keys %$attrs) {
		if ($attrs->{$a}->{'NamespaceURI'} eq 'http://template.sesse.net/') {
			delete $attrs->{$a};
		}
	}

	$self->SUPER::start_element($data);
}
	
sub end_element {
	my ($self, $data) = @_;

	return if ($data->{'NamespaceURI'} eq 'http://template.sesse.net/');
	
	$self->SUPER::end_element($data);
}

1;
