<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
#
# pod2xml.pl

#
# main routine
#

my $VERSION  = '0.1b';
my $mail     = "j.giebels\@instant-karma.de";
my $web      = "http://www.instant-karma.de";
my $reldate  = "03/03/2000";
my $infile   = shift;
my $outfile  = shift;

if ($infile eq "-h" or $infile eq "--help" or $infile eq "-?" or $infile eq "/?") {
	&amp;usage;
}
elsif ($infile) {
	&amp;Input;
}
else {
	print "\nusage:\n\n$0 --infile=&lt;name&gt; --outfile=&lt;name&gt;\n\n$0 --option=&lt;[-h][--help][/?][-?]&gt; for help\n";
}

#
# usagepage at option -h --help -? /?
#

sub usage {
	$usage =&lt;&lt;END_OF_USAGE;

	usage:  $0 --infile=&lt;name&gt; --outfile=&lt;name&gt;
	        $0 --otion=&lt;[-h][--help][/?][-?]&gt;

	  --help       - prints this message.
	  -h
	  /?
	  -?

	  --infile     - filename for the pod to convert from

	  --outfile    - filename for the resulting xml file

	$0, version $VERSION, released $reldate

	please send bugreports, suggestions and related stuff to
	$mail
	
	the dokumentation is provided within this package as pod
	or visit $web for further details and help.
	thank you for using $0

END_OF_USAGE
	print $usage;
}

#
# sub input - read infile from given name $infile
#

sub Input {
	open (INPUT, "$infile") or die "error: can't open $infile\ncause: $!\n";
	while (&lt;INPUT&gt;) {
		if (/(^=\w*)/ .. /(^=cut)/) {
			push @rawdoku, $_;
		}
	}
	&amp;XMLout;
}

#
# sub XMLout - XML output to given filename $outfile
#
# parameter:
#
# $outfile - filename for xml-output
# $line    - string for xml-conversion

sub XMLout {
	# create xml-file and a valid header
	open (OUTPUT, "&gt; $outfile") or die "error: can't open $outfile\cause: $!\n";
	print OUTPUT "&lt;?xml version=\"1.0\"?&gt;&lt;pod2xml_$infile&gt;";
	$ih1 = 0;$ih2 = 0;$it  = 0;$ib = 0;$io = 0;
	# check for pod-tag
	foreach $line(@rawdoku) {
		if ($line =~ /(^=\w*\b)/) {

			# split pod-tags
			$line =~ s/(^=\w*\b)//;
			$value = $line;
			$line = $1;
			$line =~ s/^=//;
			chomp $line;
			chomp $value;

			# kill other tags
			$value =~ s/E&lt;\w*&gt;//g; # remove escapes
			$value =~ s/[A-Z]{1}?&lt;//g; # remove .&lt;
			$value =~ s/&gt;//g; # remove &gt;
			$value =~ s/&lt;//g; # remove &lt;
			$value =~ s/&amp;//g; # remove &amp;

			if (not $line) {
				$line = $value;
			}
			if ($line eq "head1") {
				if ($ih1 == 2) {
					print OUTPUT "&lt;/headline1&gt;";
					$ih1 = 1;
				}
				else {
					$ih1 = 1;
				}
			}
			elsif ($line eq "head2") {
				if ($ih2 == 2) {
					print OUTPUT "&lt;/headline2&gt;";
					$ih2 = 1;
				}
				else {
					$ih2 = 1;
				}
			}
			elsif ($line eq "over") {
				if ($ih1 == 2) {
					print OUTPUT "&lt;/headline1&gt;";
					$ih1 = 0;
				}
				elsif ($ih2 == 2) {
					print OUTPUT "&lt;/headline2&gt;";
					$ih2 = 0;
				}
				$io = 1;
				print OUTPUT "&lt;list&gt;$value";
			}
			elsif ($line eq "back") {
				if ($it == 2) {
					print OUTPUT "&lt;/item&gt;";
					$it = 0;
				}
				$ib = 1;
				print OUTPUT "&lt;/list&gt;";
			}
			elsif ($line eq "item") {
				if ($it == 2) {
					print OUTPUT "&lt;/item&gt;";
					$it = 1;
				}
				else {
					$it = 1;
				}
			}
			elsif ($line eq "cut") {
				$line = "";
			}
			elsif ($line eq "pod") {
				$line = "";
			}
		}
		if ($ih1 == 1) {
			if ($ih2 == 2) {
				print OUTPUT "&lt;/headline2&gt;";
				$ih2 = 0;
			}
			elsif ($it == 2) {
				print OUTPUT "&lt;/item&gt;";
				$it = 0;
			}
			print OUTPUT "&lt;headline1&gt;$value";
			$ih1 = 2;
		}
		elsif ($ih2 == 1) {
			if ($ih1 == 2) {
				print OUTPUT "&lt;/headline1&gt;";
				$ih1 = 0;
			}
			elsif ($it == 2) {
				print OUTPUT "&lt;/item&gt;";
				$it = 0;
			}
			print OUTPUT "&lt;headline2&gt;$value";
			$ih2 = 2;
		}
		elsif ($it == 1) {
			if ($ih1 == 2) {
				print OUTPUT "&lt;/headline1&gt;";
				$ih1 = 0;
			}
			elsif ($ih2 == 2) {
				print OUTPUT "&lt;/headline2&gt;";
				$ih2 = 0;
			}
			print OUTPUT "&lt;item&gt;$value";
			$it = 2;
		}
		elsif ($ib == 1) {
			$ib = 0;
		}
		elsif ($io == 1) {
			$io = 0;
		}
		else {
			# kill other tags
			$line =~ s/E&lt;\w*&gt;//g; # remove escapes
			$line =~ s/[A-Z]{1}?&lt;//g; # remove .&lt;
			$line =~ s/&gt;//g; # remove &gt;
			$line =~ s/&lt;//g; # remove &lt;
			$line =~ s/&amp;//g; # remove &amp;
			print OUTPUT "&lt;content&gt;$line&lt;/content&gt;";
		}
	}
	print OUTPUT "&lt;/headline1&gt;" if ($ih1 == 2);
	print OUTPUT "&lt;/headline2&gt;" if ($ih2 == 2);
	print OUTPUT "&lt;/item&gt;" if ($it == 2);
	print OUTPUT "&lt;content&gt;this XML-stream was created with pod2xml v.$VERSION&lt;/content&gt;&lt;/pod2xml_$infile&gt;";
	print "\neverything is pretty fine.\nyour xml-file: $outfile was created successfully.\nthank you for using $0, $VERSION.\n";
}

############################################################

=head1 name

pod2xml - perl script for converting pod-dokumentation into a valid xml-file

=head1 synopsis

    pod2xml --infile=E&lt;lt&gt;[name]E&lt;gt&gt; --outfile=E&lt;lt&gt;[name]E&lt;gt&gt;
    
    pod2xml --option=E&lt;lt&gt;[-h][--help][-?][/?]E&lt;gt&gt;

=head1 history

v. 0.1b		03/03/2000	release of first beta version

v. 0.01a	02/20/2000	initial version

=head1 description

pod2xml is a perl based script, that helps you, converting pod (embedded dokumentation) to
a valid XML file version 1.0. this is used, e.g. if you want to build a xml-dokumentation 
server.
the output is hard to edit, but feel free do edit the code for your use. only thing to do,
is to leave this dokumentation untouched. it would be nice, if you send me a modified version.

=head1 README

pod2xml converts embedded perl dokumentation,
known as pod, to a valid xml-stream.
the inputfile can be any ascii formatted file
with pdo-tags included.
this is a very early beta-version, so use it
carefully.

=head1 arguments

the following arguments can be used with pod2xml

=over 4

=item --infile=E&lt;lt&gt;[name]E&lt;gt&gt;

the inputfile wich contains the pod-dokumentation. it can be a *.pl, *.pm or *.pod file
but also any other inputfile in ascii format with pod-tags.

=item --outfile=E&lt;lt&gt;[name]E&lt;gt&gt;


the outputfile wich contains the xml-stream. we suggest to use *.xml extension but also any

other outputfilename can be given.

=item --option=E&lt;lt&gt;[-h][--help][-?][/?]E&lt;gt&gt;

display the helppage of pod2xml

=back

=head1 future

-easier configuration of output via configfile

-support of EE&lt;lt&gt;escapeE&lt;gt&gt; sequences

=head1 limitations

pod-tags not implemented yet:

cut - planned in further version
pod - planned in further version
FMT - these tags are only for the FMT formater


format codes not implemented yet:

EE&lt;lt&gt;escapeE&lt;gt&gt; - will be removed completely
FE&lt;lt&gt;fileE&lt;gt&gt;   - filename, path to file will be shown
XE&lt;lt&gt;indexE&lt;gt&gt;  - indexentry, entry will be shown, none indexing

BE&lt;lt&gt;textE&lt;gt&gt; - bold, ignored
CE&lt;lt&gt;codeE&lt;gt&gt; - nonepropotional for code, ignored
IE&lt;lt&gt;textE&lt;gt&gt; - cursiv, ignored
LE&lt;lt&gt;nameE&lt;gt&gt; - link, ignored
SE&lt;lt&gt;textE&lt;gt&gt; - spacebreak, ignored
ZE&lt;lt&gt;E&lt;gt&gt;     - zero character, ignored

not supported keys:

&amp; - et
&lt; - smaller
&gt; - greater

=pod OSNAMES

any

=pod SCRIPT CATEGORIES

CPAN/Administrative

=head1 author

jan giebels, E&lt;lt&gt;j.giebels@instant-karma.deE&lt;gt&gt;.

=head1 bugs

please send bugreports, suggestions and related stuff to j.giebels@instant-karma.de
or visit http://www.instant-karma.de for further versions, details and help.

=head1 see also

perl(1)

=head1 copyright

this program is distributed under the artistic license.

=cut
</pre></body></html>