Ignore:
Timestamp:
2016-04-20T22:50:52+12:00 (8 years ago)
Author:
davidb
Message:

Changes in the Java code to support the new approach taken to client-side XSLT (using Saxon-CE JS library in the browser -- see next commit). Also some better error reporting when processing XSLT files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/Dictionary.java

    r26257 r30477  
    140140    }
    141141
     142        public static String processArgs(String initial, String args[])
     143        {
     144        // If the string contains arguments we have to insert them.
     145        StringBuffer complete = new StringBuffer();
     146        // While we still have initial string left.
     147        while (initial.length() > 0 && initial.indexOf('{') != -1 && initial.indexOf('}') != -1)
     148        {
     149            // Remove preamble
     150            int opening = initial.indexOf('{');
     151            int closing = initial.indexOf('}');
     152            int comment_mark = initial.indexOf('-', opening); // May not exist
     153            if (comment_mark > closing)
     154            { // May also be detecting a later comment
     155                comment_mark = -1;
     156            }
     157            complete.append(initial.substring(0, opening));
     158           
     159            // Parse arg_num
     160            String arg_str = null;
     161            if (comment_mark != -1)
     162            {
     163                arg_str = initial.substring(opening + 1, comment_mark);
     164            }
     165            else
     166            {
     167                arg_str = initial.substring(opening + 1, closing);
     168            }
     169            if (closing + 1 < initial.length())
     170            {
     171                initial = initial.substring(closing + 1);
     172            }
     173            else
     174            {
     175                initial = "";
     176            }
     177            int arg_num = Integer.parseInt(arg_str);
     178            // Insert argument
     179            if (args != null && 0 <= arg_num && arg_num < args.length)
     180            {
     181                complete.append(args[arg_num]);
     182            }
     183        }
     184        complete.append(initial);
     185        return complete.toString();     
     186    }
     187   
    142188    /**
    143189     * Used to retrieve a property value from the Locale specific
     
    162208    public String get(String key, String args[])
    163209    {
     210        // The following 'argsStr' doesn't appear to be used in rest of method, so
     211        // commenting out
     212        /*
    164213        String argsStr = "";
    165214        if (args != null)
     
    170219            }
    171220        }
    172 
     221        */
     222       
    173223        if (this.raw == null)
    174224        {
     
    186236                return initial;
    187237            }
     238
     239            return processArgs(initial,args);
     240            /*
    188241            // If the string contains arguments we have to insert them.
    189242            StringBuffer complete = new StringBuffer();
     
    228281            complete.append(initial);
    229282            return complete.toString();
     283            */
    230284        }
    231285        catch (Exception e)
Note: See TracChangeset for help on using the changeset viewer.