[sword-svn] r84 - trunk/modules/perlconverters

chrislit at www.crosswire.org chrislit at www.crosswire.org
Fri Apr 27 17:22:02 MST 2007


Author: chrislit
Date: 2007-04-27 17:22:01 -0700 (Fri, 27 Apr 2007)
New Revision: 84

Modified:
   trunk/modules/perlconverters/zef2osis.pl
Log:
added some header translation

Modified: trunk/modules/perlconverters/zef2osis.pl
===================================================================
--- trunk/modules/perlconverters/zef2osis.pl	2007-04-26 11:46:12 UTC (rev 83)
+++ trunk/modules/perlconverters/zef2osis.pl	2007-04-28 00:22:01 UTC (rev 84)
@@ -74,8 +74,6 @@
 $mon++;
 $date = sprintf("%04d\-%02d\-%02d", $year, $mon, $mday);
 
-print OUTF "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osis xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.$osisVersion.xsd\">\n<osisText osisRefWork=\"Bible\" xml:lang=\"en\" osisIDWork=\"$osisWork\">\n<header>\n<revisionDesc><date>$date<\/date><p>initial OSIS 2.1.1 version<\/p><\/revisionDesc>\n<work osisWork=\"$osisWork\">\n<title><\/title>\n<creator role=\"encoder\">zef2osis.pl by Chris Little www.crosswire.org<\/creator>\n<type type=\"OSIS\">Bible<\/type>\n<identifier type=\"OSIS\">$osisWork<\/identifier>\n<source>Zefania XML<\/source>\n<language type=\"IETF\"><\/language>\n<scope><\/scope>\n<refSystem>Bible<\/refSystem>\n<\/work>\n<\/header>\n";
-
 open (INF, $ARGV[1]);
 @data = <INF>;
 close (INF);
@@ -96,14 +94,18 @@
 $enc = "utf8";
 
 $q = 0;
+$hd_source = "<source>Zefania XML (http:\/\/www.zefania.de)<\/source>\n";
+$lang = "";
+$hd_title = "<title><\/title>\n";
+$hd_description = "<description><\/description>\n";
+
 foreach $line (@data) {
+    if ($enc ne "utf8") {
+      utf8::encode($line);
+    }
 
     if ($pr == 1) {
 
-	if ($enc ne "utf8") {
-	    utf8::encode($line);
-	}
-
 	$line =~ s/[\r\n]+/\n/g;
 	$line =~ s/^\s+//;
 	$line =~ s/\s+$//;
@@ -178,9 +180,44 @@
 	$enc = "latin1";
     }
     elsif ($line =~ /<\/INFORMATION>/) {
+	print OUTF "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osis xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.$osisVersion.xsd\">\n<osisText osisRefWork=\"Bible\" xml:lang=\"$lang\" osisIDWork=\"$osisWork\">\n<header>\n<revisionDesc><date>$date<\/date><p>initial OSIS 2.1.1 version<\/p><\/revisionDesc>\n<work osisWork=\"$osisWork\">\n$hd_title$hd_contributor$hd_creator<creator role=\"encoder\">zef2osis.pl from http:\/\/www.crosswire.org<\/creator>\n<date><\/date>\n$hd_description$hd_publisher<type type=\"OSIS\">Bible<\/type>\n<identifier type=\"OSIS\">$osisWork<\/identifier>\n$hd_source<language type=\"IETF\">$lang<\/language>\n$hd_rights<scope><\/scope>\n<refSystem>Bible<\/refSystem>\n<\/work>\n<\/header>\n";
+	
 	$pr = 1;
     }
-
+    else {
+	if ($line =~ /(<title>.+?<\/title>)/) {
+	    $hd_title = "$1\n";
+	}
+	elsif ($line =~ /(<creator>.+?<\/creator>)/) {
+	    $hd_creator = "$1\n";
+	}
+	elsif ($line =~ /(<contributor>.+?<\/contributor>)/) {
+	    $hd_contributor = "$1\n";
+	}
+	elsif ($line =~ /(<description>.+?<\/description>)/) {
+	    $hd_description = "$1\n";
+	}
+	elsif ($line =~ /(<source>.+?<\/source>)/) {
+	    $hd_source = $1;
+	    $hd_source =~ s/<\/source>/\nvia Zefania XML (http:\/\/www.zefania.de)<\/source>\n/;
+	}
+	elsif ($line =~ /(<rights>.+?<\/rights>)/) {
+	    $hd_rights = "$1\n";
+	}
+	elsif ($line =~ /(<publisher>.+?<\/publisher>)/) {
+	    $hd_publisher = "$1\n";
+	}
+	elsif ($line =~ /<language>(.+?)<\/language>/) {
+	    $lang = $1;
+	    if ($lang eq "ENG") {
+		$lang = "en";
+	    }
+	    elsif ($lang eq "GER") {
+		$lang = "de";
+	    }
+	    else {$lang = ""};
+	}
+    }
 }
 
 print OUTF "<\/osisText>\n";




More information about the sword-cvs mailing list