| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | require 5; | 
| 3 |  |  |  |  |  |  | package Pod::Simple::XMLOutStream; | 
| 4 | 29 |  |  | 29 |  | 38540 | use strict; | 
|  | 29 |  |  |  |  | 95 |  | 
|  | 29 |  |  |  |  | 850 |  | 
| 5 | 29 |  |  | 29 |  | 150 | use Carp (); | 
|  | 29 |  |  |  |  | 59 |  | 
|  | 29 |  |  |  |  | 406 |  | 
| 6 | 29 |  |  | 29 |  | 2422 | use Pod::Simple (); | 
|  | 29 |  |  |  |  | 76 |  | 
|  | 29 |  |  |  |  | 693 |  | 
| 7 | 29 |  |  | 29 |  | 147 | use vars qw( $ATTR_PAD @ISA $VERSION $SORT_ATTRS); | 
|  | 29 |  |  |  |  | 62 |  | 
|  | 29 |  |  |  |  | 2872 |  | 
| 8 |  |  |  |  |  |  | $VERSION = '3.43'; | 
| 9 |  |  |  |  |  |  | BEGIN { | 
| 10 | 29 |  |  | 29 |  | 589 | @ISA = ('Pod::Simple'); | 
| 11 | 29 | 50 |  |  |  | 19539 | *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG; | 
| 12 |  |  |  |  |  |  | } | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | $ATTR_PAD = "\n" unless defined $ATTR_PAD; | 
| 15 |  |  |  |  |  |  | # Don't mess with this unless you know what you're doing. | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | $SORT_ATTRS = 0 unless defined $SORT_ATTRS; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub new { | 
| 20 | 469 |  |  | 469 | 1 | 6663 | my $self = shift; | 
| 21 | 469 |  |  |  |  | 1705 | my $new = $self->SUPER::new(@_); | 
| 22 | 469 |  | 50 |  |  | 2540 | $new->{'output_fh'} ||= *STDOUT{IO}; | 
| 23 | 469 |  |  |  |  | 1571 | $new->keep_encoding_directive(1); | 
| 24 |  |  |  |  |  |  | #$new->accept_codes('VerbatimFormatted'); | 
| 25 | 469 |  |  |  |  | 1037 | return $new; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | sub _handle_element_start { | 
| 31 |  |  |  |  |  |  | # ($self, $element_name, $attr_hash_r) | 
| 32 | 1870 |  |  | 1870 |  | 3246 | my $fh = $_[0]{'output_fh'}; | 
| 33 | 1870 |  |  |  |  | 2708 | my($key, $value); | 
| 34 | 1870 |  |  |  |  | 2380 | DEBUG and print STDERR "++ $_[1]\n"; | 
| 35 | 1870 |  |  |  |  | 5843 | print $fh "<", $_[1]; | 
| 36 | 1870 | 100 |  |  |  | 3633 | if($SORT_ATTRS) { | 
| 37 | 1160 |  |  |  |  | 1563 | foreach my $key (sort keys %{$_[2]}) { | 
|  | 1160 |  |  |  |  | 4566 |  | 
| 38 | 2043 | 100 |  |  |  | 4996 | unless($key =~ m/^~/s) { | 
| 39 | 1602 | 50 | 66 |  |  | 5214 | next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; | 
| 40 | 695 |  |  |  |  | 1953 | _xml_escape($value = $_[2]{$key}); | 
| 41 | 695 |  |  |  |  | 1772 | print $fh $ATTR_PAD, $key, '="', $value, '"'; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  | } else { # faster | 
| 45 | 710 |  |  |  |  | 977 | while(($key,$value) = each %{$_[2]}) { | 
|  | 1544 |  |  |  |  | 4555 |  | 
| 46 | 834 | 100 |  |  |  | 1997 | unless($key =~ m/^~/s) { | 
| 47 | 764 | 100 | 100 |  |  | 2504 | next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; | 
| 48 | 197 |  |  |  |  | 459 | _xml_escape($value); | 
| 49 | 197 |  |  |  |  | 502 | print $fh $ATTR_PAD, $key, '="', $value, '"'; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  | } | 
| 53 | 1870 |  |  |  |  | 4493 | print $fh ">"; | 
| 54 | 1870 |  |  |  |  | 3693 | return; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub _handle_text { | 
| 58 | 1278 |  |  | 1278 |  | 1633 | DEBUG and print STDERR "== \"$_[1]\"\n"; | 
| 59 | 1278 | 100 |  |  |  | 2562 | if(length $_[1]) { | 
| 60 | 1267 |  |  |  |  | 1898 | my $text = $_[1]; | 
| 61 | 1267 |  |  |  |  | 2722 | _xml_escape($text); | 
| 62 | 1267 |  |  |  |  | 2072 | print {$_[0]{'output_fh'}} $text; | 
|  | 1267 |  |  |  |  | 3320 |  | 
| 63 |  |  |  |  |  |  | } | 
| 64 | 1278 |  |  |  |  | 3321 | return; | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | sub _handle_element_end { | 
| 68 | 1870 |  |  | 1870 |  | 2331 | DEBUG and print STDERR "-- $_[1]\n"; | 
| 69 | 1870 |  |  |  |  | 2378 | print {$_[0]{'output_fh'}} "", $_[1], ">"; | 
|  | 1870 |  |  |  |  | 4483 |  | 
| 70 | 1870 |  |  |  |  | 3322 | return; | 
| 71 |  |  |  |  |  |  | } | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | 
| 74 |  |  |  |  |  |  | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | sub _xml_escape { | 
| 77 | 2159 |  |  | 2159 |  | 3350 | foreach my $x (@_) { | 
| 78 |  |  |  |  |  |  | # Escape things very cautiously: | 
| 79 | 2159 | 50 |  |  |  | 8662 | if ($] ge 5.007_003) { | 
| 80 | 2159 |  |  |  |  | 5925 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(utf8::native_to_unicode(ord($1))).';'/eg; | 
|  | 862 |  |  |  |  | 3490 |  | 
| 81 |  |  |  |  |  |  | } else { # Is broken for non-ASCII platforms on early perls | 
| 82 | 0 |  |  |  |  | 0 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/''.(ord($1)).';'/eg; | 
|  | 0 |  |  |  |  | 0 |  | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  | # Yes, stipulate the list without a range, so that this can work right on | 
| 85 |  |  |  |  |  |  | #  all charsets that this module happens to run under. | 
| 86 |  |  |  |  |  |  | } | 
| 87 | 2159 |  |  |  |  | 3029 | return; | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | 
| 91 |  |  |  |  |  |  | 1; | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | __END__ |