- Timestamp:
- 2012-08-20T18:09:15+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/bin/script/convert_coll_from_gs2.pl
r25731 r26124 716 716 } 717 717 718 sub format_if_or { 719 my ($format, $node_type) = @_; 720 721 # while we find nested if/or statements, recurse to find more nested if/or statements, 722 # and try to expand (process) these nested statements starting from innermost going to outermost 723 724 while($format =~ m/^.*\{(?:If|Or)\}\{[^\}\{]*\{/) { # contains nested if/or statement, expand it 725 726 my ($prefix, $nested_to_process, $suffix) = $format =~ m/^(.*\{(?:If|Or)\}\{[^\}\{]*)(\{[^\}]*\}\s*\{[^\}]*\})(.*)$/g; # recursion step 727 728 #print STDERR "prefix: |$prefix|\n\nnested: |$nested_to_process|\n\nsuffix: |$suffix|\n\n"; 729 $format = $prefix . &format_if_or($nested_to_process, $node_type) . $suffix; 730 } 731 732 if($format =~ m/\{(If|Or)\}\{[^\}\{]*\}/g) { # base step: contains if/or statement(s), but none nested 733 # expand them 734 $format =~ s/\{If\}\{([^\}]*)\}/&format_if($1, $node_type)/eg; 735 $format =~ s/\{Or\}\{([^\}]*)\}/&format_or($1)/eg; 736 } 737 return $format; 738 } 739 718 740 sub write_format { 719 741 my ($writer, $old_format, $node_type) = @_; … … 723 745 $old_format =~ s/\\\"/\"/g; 724 746 #convert [] to <gsf:...> 725 # assume no nesting {If} or {Or} for now 726 $old_format =~ s/\{If\}\{([^\}]*)\}/&format_if($1, $node_type)/eg; 727 $old_format =~ s/\{Or\}\{([^\}]*)\}/&format_or($1)/eg; 747 # now handles nested {If} and {Or} 748 $old_format = &format_if_or($old_format, $node_type); 728 749 $old_format =~ s/\[Text\]/\<gsf:text\/\>/g; 729 750 $old_format =~ s/\[num\]/\<gsf:num\/\>/g;
Note:
See TracChangeset
for help on using the changeset viewer.