The Perl Review XML description

brian_d_foy on 2002-12-31T10:33:06

I have slowly been working on the TPR production system. After 7 issues I think I know the things I need to automate and how I need to automate them. The biggest mess at the moment is that I do not have the h2xs equivalent for a new issue, which is basically a directory with a lot of files in it that looks very similar to the directories of other issues. With each issue, I abstract the process a little bit more.

I finally finished a first pass at an XML description of an issue that specifies the things which other parts of the system cannot figure out on their own.

This is the actual description for the next issue, due out tomorrow (if the power does not go out and the phone lines stay up). I use a very simple XML format.





Paying Homage to Perl (PHP) Ed Summers php 4


Jotto: The Five-Letter Word Game Kevin Jackson-Mead jotto 1


Processing RSS Files with XSL-T Dr. A J Trickett xslt 2


Separating code, presentation, and configuration brian d foy config 3




From that, I generate a bunch of files that the rest of the process needs. Previously, I had to affect each of these files individually. Now the make process builds them if I update the XML description. My xml2papers script (so called because its main purpose is the creation of the "papers" file) uses XML::Simple to access the information.

#!/usr/bin/perl

use Data::Dumper; use XML::Simple;

my $xs = XML::Simple->new();

my $ref = $xs->XMLin( $ARGV[0] );

my $issue = $ref->{issue};

#print Data::Dumper::Dumper( $ref );

print "Writing volume file\n"; open FILE, "> volume.tex" or die; print FILE $ref->{number}; close FILE;

print "Writing issue file\n"; open FILE, "> issue.tex" or die; print FILE $issue->{number}; close FILE;

print "Writing date file\n"; open FILE, "> publication_date.tex" or die; print FILE $issue->{publication_date}{value}; close FILE;

my $articles = $issue->{article};

print "Writing articles file\n"; open FILE, "> articles" or die; print FILE join " ", map { $_->{file} } @$articles; close FILE;

print "Writing papers file\n"; open FILE, "> papers.tex" or die; foreach my $hash ( sort { $a->{order} <=> $b->{order} } @$articles ) { my( $title, $author, $file ) = @$hash{ qw( title author file ) }; print FILE <<"HERE"; \\Title{$title} \\coltoctitle{$title} \\coltocauthor{$author} \\label{$file} \\import{$file} HERE } close FILE;