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

refdoc at crosswire.org refdoc at crosswire.org
Sat Aug 14 07:33:57 MST 2010


Author: refdoc
Date: 2010-08-14 07:33:57 -0700 (Sat, 14 Aug 2010)
New Revision: 295

Modified:
   trunk/modules/perlconverters/xrefadd.pl
Log:
some cleaning up and start to introduce xml::dom logic


Modified: trunk/modules/perlconverters/xrefadd.pl
===================================================================
--- trunk/modules/perlconverters/xrefadd.pl	2010-08-13 22:17:46 UTC (rev 294)
+++ trunk/modules/perlconverters/xrefadd.pl	2010-08-14 14:33:57 UTC (rev 295)
@@ -38,6 +38,7 @@
 ## sword-support at crosswire.org
 
 #########################################################################
+use XML::DOM;
 sub vs2osis {
 
         my $return = `vs2osisref "$_[0]" "$_[1]" $_[2]`;
@@ -54,7 +55,10 @@
 
 
 if (scalar(@ARGV) < 2) {
-    print "xrefadd.pl -- adds crossreferences to OSIS files. Usage: xrefadd.pl <input OSIS filename> <input xreffile> [-o <output-file>] [-l <xreflocale>].\n";
+    print "xrefadd.pl -- adds crossreferences to OSIS files. 
+        \t It expects as input a valid OSIS file and a file with crossreferences formatted as follows:
+        \t verse usfm-xref
+        \n \t Usage: xrefadd.pl <input OSIS filename> <input xreffile> [-o <output-file>] [-l <xreflocale>].\n";
     exit (-1);
 }
 
@@ -73,36 +77,25 @@
 else {
     $locale = "en";
 }
-open (OUTF, ">", "$outputFilename") or die "Could not open file $outputFilename for writing.";
 
-open (INF, "<", $ARGV[0]);
- at data = <INF>;
-close (INF);
+$osis = new XML::DOM;
+$osis->parsefile($ARGV[0]);
 
 open (INF, "<", $ARGV[1]);
 @xref = <INF>;
 close (INF);
 
 $c_book = "Gen";
-$c_chapter="1"
+$c_chapter="1";
 
-foreach (@data) {
+foreach (@xref) {
 
-    if (/xml:lang\=\"(.+?)\"/) { 
-        $locale=$1;
-        print "This document is in the locale of ".$locale."\n";
-        }
-    if (/<div\ type\=\"book\"\ osisID=\"(.+?)\">/) { 
-        $c_book=$1;
-        print "\n"."Now working on ".$c_book."\n";
-        }
-    if (/<chapter\ sID\=\".*?\.([0-9]+)\"/) { 
-        $c_chapter=$1;
-        print ".";
-        }
+#insert the xref in the right place in the OSIS document 
     
-    s/<reference>(.*?)<\/reference>/&vs2osis($1,$c_book.$c_chapter,$locale)/eg;
+
+
+
     }
-print (OUTF @data);    
-close OUTF;
+$osis->printToFile ($outputFilename) or die ("$outputFilename could not get opened to write");
+
     
\ No newline at end of file




More information about the sword-cvs mailing list