[sword-svn] r300 - trunk/modules/crossreferences

refdoc at crosswire.org refdoc at crosswire.org
Wed Aug 18 14:22:27 MST 2010


Author: refdoc
Date: 2010-08-18 14:22:27 -0700 (Wed, 18 Aug 2010)
New Revision: 300

Modified:
   trunk/modules/crossreferences/xrefmake.pl
Log:
in OSIS cross reference markers introduced. Also now possible to create cross references based on a different canon.


Modified: trunk/modules/crossreferences/xrefmake.pl
===================================================================
--- trunk/modules/crossreferences/xrefmake.pl	2010-08-18 19:20:55 UTC (rev 299)
+++ trunk/modules/crossreferences/xrefmake.pl	2010-08-18 21:22:27 UTC (rev 300)
@@ -99,7 +99,10 @@
         "JSB" => "Josh", "TBS" => "Tob", "SST" => "Sus", "DNT" => "Dan",
         "BLT" => "Bel", "ADE" => "AddEsth"
     );
-
+    
+    my @xref_count = qw( a b c d e f g h i j k l m n 
+                        o p q r s t u v w x z);
+                        
 my $version = "1.0";
 my $osisVersion = "2.1.1";
 
@@ -111,10 +114,14 @@
 
 
 if (scalar(@ARGV) < 3) {
-    print "xrefmake.pl -- creates a file with localised crossreferences, either in USFM or in OSIS. 
-        \t It expects as input a csvfile formatted as follows:
-        \t A space-separated list of 6 numbers, the frist three representing the originating reference, the second three the cross reference, each as <book> <chapter> <verse>.
-        \n \t Usage: xrefmake.pl <input CSV filename> <xreflocale> <USFM|OSIS>.\n";
+    print "\t xrefmake.pl 
+        \t -- creates a file with localised crossreferences, either in USFM or in OSIS. 
+        \n \t It expects as input a csvfile formatted as follows:
+        \t A space-separated list of 6 numbers, representing the originating reference and cross reference, each as <book> <chapter> <verse>.
+        \t A SWORD locale name.
+        \t Either OSIS or USFM to determine the output format
+        \t Optionally, the name of a file containing the used canon as a list of book names, each name on a single line. The default canon is that of the KJV. 
+        \n \t \b Usage: xrefmake.pl <input CSV filename> <xreflocale> <USFM|OSIS> [canon file name].\n";
     exit (-1);
 }
     
@@ -122,27 +129,46 @@
     my $locale = "$ARGV[1]";
     
     my $type = "$ARGV[2]";
+    
+    if (exists ($ARGV[3])) {
+        
+        @bookname = `cat $ARGV[3]` or die $!;
+        
+    }
 
-
     my $csv = Text::CSV->new();
     
-    my ($ref, $o_ref, $xref, $xrefList);    
+    my ($ref, $o_ref, $xref, $xrefList, $chapter, $chapter_now, $xref_counter);    
     open (CSV, "<", $file) or die $!;
 
     if ($type eq "OSIS") {
-       $o_ref = "GEN.0.0";
+    
+       $o_ref 		= "GEN.1.1";
+       $chapter 	= 1;
+       $xref_counter 	= 0;
+    
        while (<CSV>) {
            
            if ($csv->parse($_)) {
                 my @columns = $csv->fields();
                 $ref = "$OSISbook{ $bookname[ $columns[0] -1 ] }.$columns[1].$columns[2]";
                 $xref = &parsekey( "$OSISbook{ $bookname[ $columns[3] -1 ] }.$columns[4].$columns[5]", $locale );
+                $chapter_now = $columns[1];
+                
                 if ($ref eq $o_ref) {
                     print &vs2osis($xref,$o_ref,$locale); 
                 }
                 else { 
-                    print "</note>\n\$\$\$$ref\n<note type=\"crossreference\" osisID=\"$ref!crossReference\" osisRef=\"$ref\">".&vs2osis($xref,$o_ref,$locale)."; ";
+
+                    print "</note>\n\$\$\$$ref\n<note n=\"$xref_count[$xref_counter]\" type=\"crossreference\" osisID=\"$ref!crossReference.$xref_count[$xref_counter]\" osisRef=\"$ref\">".&vs2osis($xref,$o_ref,$locale)."; ";
                     $o_ref = $ref;
+                    if ($chapter_now == $chapter) {
+                        $xref_counter = ($xref_counter + 1) % 26 ;
+                    }
+                    else {
+                        $xref_counter =0;
+                        $chapter = $chapter_now;	 
+                    }
                 }                        
             
             } 




More information about the sword-cvs mailing list