Changeset 8643


Ignore:
Timestamp:
2004-11-23T16:51:01+13:00 (19 years ago)
Author:
nzdl
Message:

metadata macros now work, hopefully

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GS2MacroResolver.java

    r8616 r8643  
    6161   
    6262    public String resolve(String text, String lang, String scope, String doc_oid, DBInfo info) {
    63     System.err.println("resolving macros for "+text);
     63    //System.err.println("resolving macros for "+text);
    6464    if (scope.equals(SCOPE_TEXT) && text_macros.size()==0) return text;
    6565    if (scope.equals(SCOPE_META) && metadata_macros.size() ==0) return text;
    66    
     66
     67    DBInfo root_info = null;
    6768    boolean new_lang = false;
    6869    if (this.lang == null || !this.lang.equals(lang) ) {
     
    9192        break;
    9293        case TYPE_META:
    93         if (text.matches(m.macro)) {
     94        // for some reason, this matches() never matches
     95        //if (text.matches(".*"+m.macro+".*")) {
     96        if (info == null) {
     97            info = gdbm_src.getInfo(doc_oid);
    9498            if (info == null) {
    95             info = gdbm_src.getInfo(doc_oid);
    96             if (info == null) {
    97                 break;
    98             }
    99             String value = info.getInfo(m.text);
    100             if (value != null) {
    101                 text = text.replaceAll(m.macro, value);
    102             }
     99            break;
    103100            }
    104101        }
    105        
     102        String value = info.getInfo(m.text);
     103        if (value != null) {
     104            text = text.replaceAll(m.macro, value);
     105        } else {
     106            // try the root node
     107            if (root_info == null && !OID.isTop(doc_oid)) {
     108            System.err.println("top="+OID.getTop(doc_oid));
     109            root_info = gdbm_src.getInfo(OID.getTop(doc_oid));
     110            }
     111            if (root_info == null) break;
     112            value = root_info.getInfo(m.text);
     113            if (value != null) {
     114            text = text.replaceAll(m.macro, value);
     115            }
     116        }
     117        //} // if
    106118        break;
    107         }
     119        } // switch
     120       
    108121    }
    109122   
Note: See TracChangeset for help on using the changeset viewer.