scripts/exportvym
changeset 579 1c487b3dd40f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/exportvym	Fri Aug 03 14:13:35 2007 +0000
     1.3 @@ -0,0 +1,70 @@
     1.4 +#!/usr/bin/perl
     1.5 +#
     1.6 +# Script to convert vym files to arbitrary formats
     1.7 +# Using xml stylesheets
     1.8 +#
     1.9 +# written by Uwe Drechsel	<vym@insilmaril.de>
    1.10 +#
    1.11 +
    1.12 +my $version="0.1";
    1.13 +my $PARSER="xsltproc";
    1.14 +my $OUTDIR="";
    1.15 +my $INPUTDIR="";
    1.16 +my $XSL="vym2html.xsl";
    1.17 +
    1.18 +
    1.19 +use Getopt::Long;
    1.20 +GetOptions (
    1.21 +    "o=s" => \$opt_outdir,
    1.22 +	"x=s"=> \$opt_xst,
    1.23 +    "h!" => \$opt_usage ) || usage ();
    1.24 +
    1.25 +
    1.26 +
    1.27 +if ($opt_usage) {
    1.28 +    $0 =~ s#.*/##g;
    1.29 +    print <<Helpende;
    1.30 +    
    1.31 +exportvym	written by Uwe Drechsel - Version $version
    1.32 +
    1.33 +usage: $0 [-h] VYMFILE
    1.34 +
    1.35 +...TODO...
    1.36 +
    1.37 +Helpende
    1.38 +}
    1.39 +
    1.40 +
    1.41 +if ($opt_xst) { $XST=$opt_XST; }
    1.42 +if ($opt_outdir) { $OUTDIR="$opt_outdir/"; }
    1.43 +if ($#ARGV <0) 
    1.44 +{
    1.45 +	die "not enough parameters given";
    1.46 +} else
    1.47 +{
    1.48 +	# get MAPNAME
    1.49 +	$MAPNAME=pop(@ARGV);
    1.50 +	if ($MAPNAME=~/\//) 
    1.51 +	{
    1.52 +		# Get inputdir from path
    1.53 +		$MAPNAME=~/(.*\/)(.*)/;
    1.54 +		$INPUTDIR=$1;	
    1.55 +		$MAPNAME=$2;	
    1.56 +	}
    1.57 +	if ($MAPNAME=~/(.*)(\.xml)/) { $MAPNAME=$1;}
    1.58 +}
    1.59 +
    1.60 +transform();
    1.61 +
    1.62 +exit;
    1.63 +
    1.64 +########################################################
    1.65 +sub transform {
    1.66 +########################################################
    1.67 +	my $command="$PARSER -o $OUTDIR$MAPNAME.html $XSL $INPUTDIR$MAPNAME.xml"; 
    1.68 +	print "$command\n";
    1.69 +	system ($command);
    1.70 +}
    1.71 +	
    1.72 +
    1.73 +