Changeset 28780


Ignore:
Timestamp:
2013-12-19T18:27:37+13:00 (8 years ago)
Author:
ak19
Message:

Now the default version of the convert_coll_from_gs2.pl does not try to convert the GS2 format statements into GS3 format statements. Instead, the script embeds GS2 format statements in the new tag <gsf:format-gs2/>, so that GS3 does not try to process them and they are preserved so that they can be fed into the c++ binary formatconverter one at a time, so that this can process one format statement at a time. GLI will allow the user to inspect the converted format statements and correct them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/bin/script/convert_coll_from_gs2.pl

    r26343 r28780  
    2020use strict;
    2121
     22my $convert_format_stmts = 0;
     23
    2224&main();
    2325sub print_usage() {
     
    2527    print STDOUT "options:\n";
    2628   
    27     print STDOUT "   -collectdir         Directory where collection lives.\n";
    28     print STDOUT "   -verbosity          Controls the amount of output.\n";
    29     print STDOUT "   -defaultlang        The language that is considered the default (for display text etc). defaults to 'en'\n\n";
     29    print STDOUT "   -collectdir             Directory where collection lives.\n";
     30    print STDOUT "   -verbosity              Controls the amount of output.\n";
     31    print STDOUT "   -defaultlang            The language that is considered the default (for display text etc). defaults to 'en'\n";
     32    print STDOUT "   -convert_format_stmts   (Deprecated.) Switch this on if you want the old behaviour of this script, which is \n";
     33    print STDOUT "                               to process format statements using perl regular expressions.\n";
     34    print STDOUT "                               This option is deprecated in favour of using 'formatconverter' which interprets \n";
     35    print STDOUT "                               format statements directly using the same C++ parsing code as in GS2 runtime.\n\n";
    3036}
    3137
     
    3945              'verbosity/\d+/', \$verbosity,
    4046              'collectdir/.*/', \$collectdir,
    41               'defaultlang/.*/', \$defaultlang)) {
     47              'defaultlang/.*/', \$defaultlang,
     48              'convert_format_stmts', \$convert_format_stmts)) {
    4249    &print_usage();
    4350    die "\n";
     
    747754sub write_format {
    748755    my ($writer, $old_format, $node_type) = @_;
     756
     757    if($convert_format_stmts) {
     758
    749759    # replace \' with '
    750760    $old_format =~ s/\\\'/\'/g;
     
    777787    #put quotes around any atts
    778788    $old_format =~ s/=([a-z]+)([> ])/=\'$1\'$2/g;
     789    }
     790    else { # not converting format statements, leave them as GS2 format stmts,
     791    # so that formatconverter can convert them and users can oversee the conversion in GLI,
     792    # but nest the GS2 statements here in an xml tag that won't be processed by GS3
     793    $old_format = "<gsf:format-gs2>" . $old_format . "</gsf:format-gs2>";
     794    }
    779795
    780796    if ($node_type eq "document") {
Note: See TracChangeset for help on using the changeset viewer.