Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Tuesday December 31, 2002
05:33 AM

The Perl Review XML description

[ #9690 ]

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.

<?xml version="1.0"?>
<volume number="0">
<issue number="7">
    <publication_date value="January 1, 2003"/>
        <title>Paying Homage to Perl (PHP)</title>
        <author>Ed Summers</author>
        <title>Jotto: The Five-Letter Word Game</title>
        <author>Kevin Jackson-Mead</author>
        <title>Processing RSS Files with XSL-T</title>
        <author>Dr. A J Trickett</author>
        <title>Separating code, presentation, and configuration</title>
        <author>brian d foy</author>

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.

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";
\\la bel{$file}
close FILE;