#!/usr/local/bin/perl -w # Conversion of commented XML/XSL files # to .tex-files for documentation. # (c) 10.12.99 Wolfgang May, may@informatik.uni-freiburg.de # Input: an XML or XSL file # Output: TeX source, to be \input from another .tex file # which provides the document frame. # * program code is typeset in {verbatim} # * comments (enclosed by /) are typeset with LaTeX $user_file = $ARGV[0]; $output_file = $ARGV[0] . '.texx'; `rm $ARGV[0].texx`; print "Creating $output_file from $user_file\n"; # Open input and output file open user_file or die "can not open file" ; open (OUT,">>$output_file") or die "can not open output file" ; print OUT "% $output_file\n"; print OUT "% This file is automatically generated by xml2tex.pl\n"; print OUT "% from $user_file. Do not change it; change $user_file\n"; print OUT "% instead and run xml2tex.pl again.\n"; # Main difficulty: if between two long comments # and , there is no effective code, # there must be no \begin{verbatim} ... \end{verbatim}. Thus, # --> must not be translated *directly* into \begin{verbatim} # but must be delayed until verbatim output is found - and # only then, the next , i.e. # the current line is output and, if program code follows, # it has to be prefixed with '\begin{verbatim}. $beginverbatim = 0; $endverbatim = ''; # default: next line is a program code line and has to be # prefixed with '\begin{verbatim}' (this is reset if a # begin-of-comment follows). $pre = '\begin{verbatim}' . "\n"; while () { # current line contains --> (at the end): kill --> and # set $beginverbatim to 1 if ($_=~s|-->||) {$beginverbatim = 1}; # current line contains *only*