<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#
# see comments in the end
#

use XML::DT ;
my $filename = shift;
my $beginLatex = '\documentclass{article}
  \usepackage[latin1]{inputenc}
  \usepackage{t1enc}
  \bibliographystyle{plain}
  \begin{document}
';
my $endLatex = '\end{document}
';

my @aut=();

%handler=(
    '-outputenc' =&gt; 'ISO-8859-1',
#    '-default'   =&gt; sub{"&lt;$q&gt;$c&lt;/$q&gt;"},
     '-begin'  =&gt; sub{print"BEGIN\n"},
     '-end'  =&gt; sub{print"end\n";"$beginLatex$c$endLatex"},
     '-pcdata' =&gt; sub{ 
         if(inctxt('(SECTION|SUBSEC1)')) {$c =~ s/[\s\n]+/ /g; $c }
         $c },
     'RANDLIST' =&gt; sub{"\\begin{itemize}$c\\end{itemize}"},
     'AFFIL' =&gt; sub{""},
     'TITLE' =&gt; sub{
                  if(inctxt('SECTION')){"\\section{$c}"}
               elsif(inctxt('SUBSEC1')){"\\subsection{$c}"}
               else                    {"\\title{$c}"}
            },
     'GCAPAPER' =&gt; sub{"$c"},
     'PARA' =&gt; sub{"$c\n\n"},
     'ADDRESS' =&gt; sub{"\\thanks{$c}"},
     'PUB' =&gt; sub{"} $c"},
     'FNAME' =&gt; sub{" $c"},
     'EMAIL' =&gt; sub{"(\\texttt{$c}) "},
     'FRONT' =&gt; sub{"$c\n"},
     'REAR' =&gt; sub{"$c"},
     'BIB' =&gt; sub{"$c"},
     'BODY' =&gt; sub{"$c"},
     'AUTHOR' =&gt; sub{ push @aut, $c ; ""},
     'ABSTRACT' =&gt; sub{
       sprintf('\author{%s}\maketitle\begin{abstract}%s\end{abstract}',
               join ('\and', @aut) ,
               $c) },
     'CODE.BLOCK' =&gt; sub{"\\begin{verbatim}\n$c\\end{verbatim}\n"},
     'XREF' =&gt; sub{"\\cite{$v{REFLOC}}"},
     'SECTION' =&gt; sub{"$c"},
     'LI' =&gt; sub{"\\item $c"},
     'SUBSEC1' =&gt; sub{"$c"},
     'BIBLIOG' =&gt; sub{"\n\\begin{thebibliography}{1}\n$c\n\\end{thebibliography}\n"},
     'HIGHLIGHT' =&gt; sub{" \\emph{$c} "},
     'BIO' =&gt; sub{""},
     'SURNAME' =&gt; sub{" $c "},
     'CODE' =&gt; sub{"\\verb!$c!"},
     'BIBITEM' =&gt; sub{"\n\\bibitem{$c"},
);
print dt($filename,%handler); 

=head1 NAME

gcapaper2tex.pl - a perl script to translate XML gcapaper DTD to latex

=head1 SYNOPSIS

   gcapapape2tex.pl mypaper.xml &gt; mupaper.tex

=head1 notes

This is an example of the use of XML::DT module

=head1 The Code

 use XML::DT ;
 my $filename = shift;
 my $beginLatex = '\documentclass{article}
   \usepackage[latin1]{inputenc}
   \usepackage{t1enc}
   \bibliographystyle{plain}
   \begin{document}
 ';
 my $endLatex = '\end{document}
 ';

 my @aut=();

 %handler=(
     '-outputenc' =&gt; 'ISO-8859-1',
 #    '-default'   =&gt; sub{"&lt;$q&gt;$c&lt;/$q&gt;"},
      '-pcdata' =&gt; sub{ 
 	 if(inctxt('(SECTION|SUBSEC1)')) {$c =~ s/[\s\n]+/ /g; $c }
 	 $c },
      'RANDLIST' =&gt; sub{"\\begin{itemize}$c\\end{itemize}"},
      'AFFIL' =&gt; sub{""},
      'TITLE' =&gt; sub{
 		  if(inctxt('SECTION')){"\\section{$c}"}
 	       elsif(inctxt('SUBSEC1')){"\\subsection{$c}"}
 	       else                    {"\\title{$c}"}
 	    },
      'GCAPAPER' =&gt; sub{"$beginLatex $c $endLatex"},
      'PARA' =&gt; sub{"$c\n\n"},
      'ADDRESS' =&gt; sub{"\\thanks{$c}"},
      'PUB' =&gt; sub{"} $c"},
      'FNAME' =&gt; sub{" $c"},
      'EMAIL' =&gt; sub{"(\\texttt{$c}) "},
      'FRONT' =&gt; sub{"$c\n"},
      'REAR' =&gt; sub{"$c"},
      'BIB' =&gt; sub{"$c"},
      'BODY' =&gt; sub{"$c"},
      'AUTHOR' =&gt; sub{ push @aut, $c ; ""},
      'ABSTRACT' =&gt; sub{
        sprintf('\author{%s}\maketitle\begin{abstract}%s\end{abstract}',
 	       join ('\and', @aut) ,
 	       $c) },
      'CODE.BLOCK' =&gt; sub{"\\begin{verbatim}\n$c\\end{verbatim}\n"},
      'XREF' =&gt; sub{"\\cite{$v{REFLOC}}"},
      'SECTION' =&gt; sub{"$c"},
      'LI' =&gt; sub{"\\item $c"},
      'SUBSEC1' =&gt; sub{"$c"},
      'BIBLIOG' =&gt; sub{"\n\\begin{thebibliography}{1}\n$c\n\\end{thebibliography}\n"},
      'HIGHLIGHT' =&gt; sub{" \\emph{$c} "},
      'BIO' =&gt; sub{""},
      'SURNAME' =&gt; sub{" $c "},
      'CODE' =&gt; sub{"\\verb!$c!"},
      'BIBITEM' =&gt; sub{"\n\\bibitem{$c"},
 );
 print dt($filename,%handler); 

=head1 author

J.Joao Almeida (jj@di.uminho.pt)
</pre></body></html>