HTTP-OAI

 view release on metacpan or  search on metacpan

lib/HTTP/OAI/SAXHandler.pm  view on Meta::CPAN


sub end_document {
	$_[0]->SUPER::end_document();
HTTP::OAI::Debug::sax( Dumper($_[1]) );
}

# Char data is rolled together by this module
sub characters {
	my ($self,$hash) = @_;
	$self->{Text} .= $hash->{Data};
# characters are traced in {start,end}_element
#HTTP::OAI::Debug::sax( "'" . substr($hash->{Data},0,40) . "'" );
}

sub start_element {
	my ($self,$hash) = @_;
	push @{$self->{Attributes}}, $hash->{Attributes};

	# Call characters with the joined character data
	if( defined($self->{Text}) )
	{
HTTP::OAI::Debug::sax( "'".substr($self->{Text},0,40) . "'" );
		$self->SUPER::characters({Data=>$self->{Text}});
		$self->{Text} = undef;
	}

	$hash->{State} = $self;
	$hash->{Depth} = ++$self->{Depth};
HTTP::OAI::Debug::sax( (" " x $hash->{Depth}) . '<'.$hash->{Name}.'>' );
	$self->SUPER::start_element($hash);
}

sub end_element {
	my ($self,$hash) = @_;

	# Call characters with the joined character data
	$hash->{Text} = $self->{Text};
	if( defined($self->{Text}) )
	{
		# Trailing whitespace causes problems
		if( $self->{Text} =~ /\S/ )
		{
HTTP::OAI::Debug::sax( "'".substr($self->{Text},0,40) . "'" );
			$self->SUPER::characters({Data=>$self->{Text}});
		}
		$self->{Text} = undef;
	}

	$hash->{Attributes} = pop @{$self->{Attributes}} || {};
	$hash->{State} = $self;
	$hash->{Depth} = $self->{Depth}--;
HTTP::OAI::Debug::sax( (" " x $hash->{Depth}) . '  <'.$hash->{Name}.'>' );
	$self->SUPER::end_element($hash);
}

sub entity_reference {
	my ($self,$hash) = @_;
HTTP::OAI::Debug::sax( $hash->{Name} );
}

sub start_cdata {
HTTP::OAI::Debug::sax();
}

sub end_cdata {
HTTP::OAI::Debug::sax();
}

sub comment {
HTTP::OAI::Debug::sax( $_[1]->{Data} );
}

sub doctype_decl {
	# {SystemId,PublicId,Internal}
HTTP::OAI::Debug::sax( $_[1]->{Name} );
}

sub attlist_decl {
	# {ElementName,AttributeName,Type,Default,Fixed}
HTTP::OAI::Debug::sax( $_[1]->{ElementName} );
}

sub xml_decl {
	# {Version,Encoding,Standalone}
HTTP::OAI::Debug::sax( join ", ", map { defined($_) ? $_ : "null" } @{$_[1]}{qw( Version Encoding Standalone )} );
}

sub entity_decl {
	# {Value,SystemId,PublicId,Notation}
HTTP::OAI::Debug::sax( $_[1]->{Name} );
}

sub unparsed_decl {
HTTP::OAI::Debug::sax();
}

sub element_decl {
	# {Model}
HTTP::OAI::Debug::sax( $_[1]->{Name} );
}

sub notation_decl {
	# {Name,Base,SystemId,PublicId}
HTTP::OAI::Debug::sax( $_[1]->{Name} );
}

sub processing_instruction {
	# {Target,Data}
HTTP::OAI::Debug::sax( $_[1]->{Target} . " => " . $_[1]->{Data} );
}

package HTTP::OAI::FilterDOMFragment;

use vars qw( @ISA );

@ISA = qw( XML::SAX::Base );

# Trap things that don't apply to a balanced fragment
sub start_document {}
sub end_document {}
sub xml_decl {}

package XML::SAX::Debug;

use Data::Dumper;



( run in 1.383 second using v1.01-cache-2.11-cpan-d7f47b0818f )