Read from both STDIN and named files
[project-aon.git] / common / scripts / gbtopml.pl
1 #!/usr/local/bin/perl -w
2 #
3 # gbtolatex.pl
4 # 10 April 2002
5 #
6 # Creates LaTeX gamebook from XML source. This should subsequently be
7 # used to create a PDF or PostScript version.
8 #####
9
10 use strict;
11
12 my $PROGRAM_NAME = "gbtopml";
13 my $PATH_PREFIX  = "$ENV{'HOME'}/aon/data";
14 my $XML_PATH = "$PATH_PREFIX/xml";
15 my $PML_PATH = "$PATH_PREFIX/pml";
16
17 my $JAVA       = '/usr/bin/java';
18
19 # Check that all the binaries are were want them
20
21 my @BINARIES;
22 push @BINARIES, ($JAVA);
23
24 foreach (@BINARIES) {
25     if ( ! -e $_ ) {
26         die "$PROGRAM_NAME: Cannot find binary '".$_."'. Please install it.\n";
27     }
28 }
29
30 ##
31
32 unless( $ARGV[ 0 ] ) { die "Usage:\n\t${PROGRAM_NAME} book-code\n"; }
33
34 print STDERR "Reminder:\n\tDid you declare the PML character entities in the XML?\n";
35
36 my $bookCode         = $ARGV[ 0 ];
37 my $XML_SOURCE       = "";
38 my $BOOK_PATH        = "";
39 my $USE_ILLUSTRATORS = "";
40
41 if( $bookCode eq "01fftd" ) {
42     $XML_SOURCE        = "01fftd.xml";
43     $BOOK_PATH         = "lw/";
44     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
45 }
46 elsif( $bookCode eq "02fotw" ) {
47     $XML_SOURCE        = "02fotw.xml";
48     $BOOK_PATH         = "lw/";
49     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
50 }
51 elsif( $bookCode eq "03tcok" ) {
52     $XML_SOURCE        = "03tcok.xml";
53     $BOOK_PATH         = "lw/";
54     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
55 }
56 elsif( $bookCode eq "04tcod" ) {
57     $XML_SOURCE        = "04tcod.xml";
58     $BOOK_PATH         = "lw/";
59     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
60 }
61 elsif( $bookCode eq "05sots" ) {
62     $XML_SOURCE        = "05sots.xml";
63     $BOOK_PATH         = "lw/";
64     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
65 }
66 elsif( $bookCode eq "06tkot" ) {
67     $XML_SOURCE        = "06tkot.xml";
68     $BOOK_PATH         = "lw/";
69     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
70 }
71 elsif( $bookCode eq "07cd" ) {
72     $XML_SOURCE        = "07cd.xml";
73     $BOOK_PATH         = "lw/";
74     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
75 }
76 elsif( $bookCode eq "08tjoh" ) {
77     $XML_SOURCE        = "08tjoh.xml";
78     $BOOK_PATH         = "lw/";
79     $USE_ILLUSTRATORS  = ":Gary Chalk:JC Alvarez & Jonathan Blake:Jonathan Blake:";
80 }
81 elsif( $bookCode eq "09tcof" ) {
82     $XML_SOURCE        = "09tcof.xml";
83     $BOOK_PATH         = "lw/";
84     $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan Blake:";
85 }
86 elsif( $bookCode eq "10tdot" ) {
87     $XML_SOURCE        = "10tdot.xml";
88     $BOOK_PATH         = "lw/";
89     $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan Blake:";
90 }
91 elsif( $bookCode eq "11tpot" ) {
92     $XML_SOURCE        = "11tpot.xml";
93     $BOOK_PATH         = "lw/";
94     $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan Blake:";
95 }
96 elsif( $bookCode eq "12tmod" ) {
97     $XML_SOURCE        = "12tmod.xml";
98     $BOOK_PATH         = "lw/";
99     $USE_ILLUSTRATORS  = ":Brian Williams:JC Alvarez & Jonathan Blake:Jonathan Blake:";
100 }
101 else{ die "Error:\n\tUknown book code.\n"; }
102
103 print qx{$JAVA org.apache.xalan.xslt.Process -IN $XML_PATH/$XML_SOURCE -XSL $XML_PATH/pml.xsl -OUT $PML_PATH/$BOOK_PATH/$bookCode.txt -PARAM use-illustrators \"$USE_ILLUSTRATORS\"};