author | insilmaril |
Mon Aug 27 11:16:56 2007 +0000 (2007-08-27) | |
changeset 591 | 29ebf5baff1d |
permissions | -rwxr-xr-x |
insilmaril@37 | 1 |
#!/usr/bin/perl |
insilmaril@37 | 2 |
# |
insilmaril@37 | 3 |
# Script to convert vym files to arbitrary formats |
insilmaril@37 | 4 |
# Using xml stylesheets |
insilmaril@37 | 5 |
# |
insilmaril@37 | 6 |
# written by Uwe Drechsel <vym@insilmaril.de> |
insilmaril@37 | 7 |
# |
insilmaril@37 | 8 |
|
insilmaril@37 | 9 |
my $version="0.1"; |
insilmaril@37 | 10 |
my $PARSER="xsltproc"; |
insilmaril@37 | 11 |
my $OUTDIR=""; |
insilmaril@37 | 12 |
my $INPUTDIR=""; |
insilmaril@37 | 13 |
my $XSL="vym2html.xsl"; |
insilmaril@37 | 14 |
|
insilmaril@37 | 15 |
|
insilmaril@37 | 16 |
use Getopt::Long; |
insilmaril@37 | 17 |
GetOptions ( |
insilmaril@37 | 18 |
"o=s" => \$opt_outdir, |
insilmaril@37 | 19 |
"x=s"=> \$opt_xst, |
insilmaril@37 | 20 |
"h!" => \$opt_usage ) || usage (); |
insilmaril@37 | 21 |
|
insilmaril@37 | 22 |
|
insilmaril@37 | 23 |
|
insilmaril@37 | 24 |
if ($opt_usage) { |
insilmaril@37 | 25 |
$0 =~ s#.*/##g; |
insilmaril@37 | 26 |
print <<Helpende; |
insilmaril@37 | 27 |
|
insilmaril@37 | 28 |
exportvym written by Uwe Drechsel - Version $version |
insilmaril@37 | 29 |
|
insilmaril@37 | 30 |
usage: $0 [-h] VYMFILE |
insilmaril@37 | 31 |
|
insilmaril@37 | 32 |
...TODO... |
insilmaril@37 | 33 |
|
insilmaril@37 | 34 |
Helpende |
insilmaril@37 | 35 |
} |
insilmaril@37 | 36 |
|
insilmaril@37 | 37 |
|
insilmaril@37 | 38 |
if ($opt_xst) { $XST=$opt_XST; } |
insilmaril@37 | 39 |
if ($opt_outdir) { $OUTDIR="$opt_outdir/"; } |
insilmaril@37 | 40 |
if ($#ARGV <0) |
insilmaril@37 | 41 |
{ |
insilmaril@37 | 42 |
die "not enough parameters given"; |
insilmaril@37 | 43 |
} else |
insilmaril@37 | 44 |
{ |
insilmaril@37 | 45 |
# get MAPNAME |
insilmaril@37 | 46 |
$MAPNAME=pop(@ARGV); |
insilmaril@37 | 47 |
if ($MAPNAME=~/\//) |
insilmaril@37 | 48 |
{ |
insilmaril@37 | 49 |
# Get inputdir from path |
insilmaril@37 | 50 |
$MAPNAME=~/(.*\/)(.*)/; |
insilmaril@37 | 51 |
$INPUTDIR=$1; |
insilmaril@37 | 52 |
$MAPNAME=$2; |
insilmaril@37 | 53 |
} |
insilmaril@37 | 54 |
if ($MAPNAME=~/(.*)(\.xml)/) { $MAPNAME=$1;} |
insilmaril@37 | 55 |
} |
insilmaril@37 | 56 |
|
insilmaril@37 | 57 |
transform(); |
insilmaril@37 | 58 |
|
insilmaril@37 | 59 |
exit; |
insilmaril@37 | 60 |
|
insilmaril@37 | 61 |
######################################################## |
insilmaril@37 | 62 |
sub transform { |
insilmaril@37 | 63 |
######################################################## |
insilmaril@37 | 64 |
my $command="$PARSER -o $OUTDIR$MAPNAME.html $XSL $INPUTDIR$MAPNAME.xml"; |
insilmaril@37 | 65 |
print "$command\n"; |
insilmaril@37 | 66 |
system ($command); |
insilmaril@37 | 67 |
} |
insilmaril@37 | 68 |
|
insilmaril@37 | 69 |
|
insilmaril@37 | 70 |