/usr/share/perl5/Pod/WSDL/Writer.pm is in libpod-wsdl-perl 0.062-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | package Pod::WSDL::Writer;
use strict;
use warnings;
use XML::Writer;
use Pod::WSDL::Utils ':writexml';
our $AUTOLOAD;
our $VERSION = "0.05";
our $INDENT_CHAR = "\t";
our $NL_CHAR = "\n";
sub new {
my ($pkg, %data) = @_;
$data{pretty} ||= 0;
$data{withDocumentation} ||= 0;
my $outStr = "";
my $me = bless {
_pretty => $data{pretty},
_withDocumentation => $data{withDocumentation},
_outStr => \$outStr,
_writer => undef,
_indent => 1,
_lastTag => '',
_faultMessageWritten => {},
_emptyMessageWritten => 0,
}, $pkg;
$me->prepare;
return $me;
}
sub wrNewLine {
my $me = shift;
my $cnt = shift;
$cnt ||= 1;
return unless $me->{_pretty};
$me->{_writer}->characters($NL_CHAR x $cnt);
}
sub wrElem {
my $me = shift;
my $type = shift;
if ($me->{_pretty}) {
if ($me->{_lastTag} eq $START_PREFIX_NAME and ($type eq $START_PREFIX_NAME or $type eq $EMPTY_PREFIX_NAME)) {
$me->{_indent}++;
} elsif ($me->{_lastTag} ne $START_PREFIX_NAME and $type eq $END_PREFIX_NAME) {
$me->{_indent}--;
}
$me->{_lastTag} = $type;
$me->{_writer}->characters($INDENT_CHAR x $me->{_indent});
}
$type .= 'Tag';
$me->{_writer}->$type(@_);
$me->wrNewLine;
}
sub wrDoc {
my $me = shift;
return unless $me->{_withDocumentation};
my $txt = shift;
my %args = @_;
my $useAnnotation = 0;
my $docTagName = "wsdl:documentation";
if (%args and $args{useAnnotation}) {
$useAnnotation = 1;
$docTagName = "documentation";
}
$txt ||= '';
$txt =~ s/\s+$//;
return unless $txt;
$me->{_writer}->characters($INDENT_CHAR x ($me->{_indent} + ($me->{_lastTag} eq $START_PREFIX_NAME ? 1 : 0))) if $me->{_pretty};
if ($useAnnotation) {
$me->{_writer}->startTag("annotation") ;
$me->wrNewLine;
$me->{_indent}++;
$me->{_writer}->characters($INDENT_CHAR x ($me->{_indent} + ($me->{_lastTag} eq $START_PREFIX_NAME ? 1 : 0))) if $me->{_pretty};
}
$me->{_writer}->startTag($docTagName);
$me->{_writer}->characters($txt);
$me->{_writer}->endTag($docTagName);
if ($useAnnotation) {
$me->wrNewLine;
$me->{_indent}--;
$me->{_writer}->characters($INDENT_CHAR x ($me->{_indent} + ($me->{_lastTag} eq $START_PREFIX_NAME ? 1 : 0))) if $me->{_pretty};
$me->{_writer}->endTag("annotation");
}
$me->wrNewLine;
}
sub output {
my $me = shift;
return ${$me->{_outStr}};
}
sub prepare {
my $me = shift;
${$me->{_outStr}} = "";
$me->{_emptyMessageWritten} = 0;
$me->{_writer} = new XML::Writer(OUTPUT => $me->{_outStr});
$me->{_writer}->xmlDecl("UTF-8");
}
sub withDocumentation {
my $me = shift;
my $arg = shift;
if (defined $arg) {
$me->{_withDocumentation} = $arg;
return $me;
} else {
return $me->{_withDocumentation};
}
}
sub pretty {
my $me = shift;
my $arg = shift;
if (defined $arg) {
$me->{_pretty} = $arg;
return $me;
} else {
return $me->{_pretty};
}
}
sub registerWrittenFaultMessage {
my $me = shift;
my $arg = shift;
return $me->{_faultMessageWritten}->{$arg} = 1;
}
sub faultMessageWritten {
my $me = shift;
my $arg = shift;
return $me->{_faultMessageWritten}->{$arg};
}
sub registerWrittenEmptyMessage {
my $me = shift;
return $me->{_emptyMessageWritten} = 1;
}
sub emptyMessageWritten {
my $me = shift;
return $me->{_emptyMessageWritten};
}
sub AUTOLOAD {
my $me = shift;
my $method = $AUTOLOAD;
$method =~ s/.*:://;
if ($method eq "DESTROY"){
return;
} else {
no strict 'refs';
$me->{_writer}->$method(@_);
}
}
1;
__END__
=head1 NAME
Pod::WSDL::Writer - Writes XML output for Pod::WSDL (internal use only)
=head1 SYNOPSIS
use Pod::WSDL::Writer;
my $wr = new Pod::WSDL::Writer(pretty => 1, withDocumentation => 1);
=head1 DESCRIPTION
This module is used internally by Pod::WSDL. By using AUTOLOADing it delegates all unknown methods to XML::Writer. It is unlikely that you have to interact directly with it. If that is the case, take a look at the code, it is rather simple.
=head1 METHODS
=head2 new
Instantiates a new Pod::WSDL::Writer. The method can take two parameters C<pretty> with a true value triggers pretty printing of the WSDL output. C<withDocumentation> with a true value produces a WSDL docuemnt containing documentation for types and methods.
=head2 wrNewLine
Has XML::Writer write a newline
=head2 wrElem
Has XML::Writer write an Element. The first argument is one of (empty|start|end), to write an empty element, a start or an end tag. The second argument signifies the name of the tag. All further arguments are attributes of the tag (does not work, when first argument is 'end')
=head2 wrDoc
Writes the string passed to the method as a <wsdl:documentation> Element
=head2 registerWrittenFaultMessage
There needs to be only one fault message per fault type. Here the client class can register fault types already written. The fault name is passed as the single argument to this method.
=head2 faultMessageWritten
Counterpart to registerWrittenFaultMessage. The client can ask if a fault message has already written. The fault name is passed as the single argument to this method.
=head2 output
Returns XML output.
=head1 EXTERNAL DEPENDENCIES
XML::Writer
=head1 EXAMPLES
see Pod::WSDL
=head1 BUGS
see Pod::WSDL
=head1 TODO
see Pod::WSDL
=head1 SEE ALSO
Pod::WSDL
=head1 AUTHOR
Tarek Ahmed, E<lt>bloerch -the character every email address contains- oelbsk.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2006 by Tarek Ahmed
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.
=cut
|