| 1 | # $Id: Debug.pm,v 1.1 2003/07/27 16:07:49 matt Exp $ |
| 2 | |
| 3 | package XML::Parser::Style::Debug; |
| 4 | use strict; |
| 5 | |
| 6 | sub Start { |
| 7 | my $expat = shift; |
| 8 | my $tag = shift; |
| 9 | print STDERR "@{$expat->{Context}} \\\\ (@_)\n"; |
| 10 | } |
| 11 | |
| 12 | sub End { |
| 13 | my $expat = shift; |
| 14 | my $tag = shift; |
| 15 | print STDERR "@{$expat->{Context}} //\n"; |
| 16 | } |
| 17 | |
| 18 | sub Char { |
| 19 | my $expat = shift; |
| 20 | my $text = shift; |
| 21 | $text =~ s/([\x80-\xff])/sprintf "#x%X;", ord $1/eg; |
| 22 | $text =~ s/([\t\n])/sprintf "#%d;", ord $1/eg; |
| 23 | print STDERR "@{$expat->{Context}} || $text\n"; |
| 24 | } |
| 25 | |
| 26 | sub Proc { |
| 27 | my $expat = shift; |
| 28 | my $target = shift; |
| 29 | my $text = shift; |
| 30 | my @foo = @{$expat->{Context}}; |
| 31 | print STDERR "@foo $target($text)\n"; |
| 32 | } |
| 33 | |
| 34 | 1; |
| 35 | __END__ |
| 36 | |
| 37 | =head1 NAME |
| 38 | |
| 39 | XML::Parser::Style::Debug - Debug style for XML::Parser |
| 40 | |
| 41 | =head1 SYNOPSIS |
| 42 | |
| 43 | use XML::Parser; |
| 44 | my $p = XML::Parser->new(Style => 'Debug'); |
| 45 | $p->parsefile('foo.xml'); |
| 46 | |
| 47 | =head1 DESCRIPTION |
| 48 | |
| 49 | This just prints out the document in outline form to STDERR. Nothing special is |
| 50 | returned by parse. |
| 51 | |
| 52 | =cut |