Changeset 4691


Ignore:
Timestamp:
2003-06-18T11:37:07+12:00 (21 years ago)
Author:
kjdon
Message:

several changes: ConfigVars replaced by a HashMap, we no longer add in the translation or config info to teh xml page before transformation: the config vars are set as parameters to teh stylesheet, the language stuff is done on the fly by teh stylesheet calling the resource bundle stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r4286 r4691  
    3737    public boolean configure() {
    3838   
    39     if (this.config==null) {
     39    if (this.config_params==null) {
    4040        System.err.println("Receptionist Error: config variables must be set before calling configure");
    4141        return false;
     
    4747   
    4848    // find the config file containing a list of actions
    49     File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(this.config.gsdl3_home_, this.config.interface_name_)));
     49    File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.INTERFACE_NAME))));
    5050    if (!interface_config_file.exists()) {
    5151        System.err.println("TransformingReceptionist: interface config file: "+interface_config_file.getPath()+" not found!");
     
    6565        ac = (Action)Class.forName("org.greenstone.gsdl3.action."+class_name).newInstance();
    6666        } catch (Exception e) {
    67         System.out.println("couldn't load in action "+class_name);
     67        System.err.println("couldn't load in action "+class_name);
    6868        e.printStackTrace();
    6969        continue;
    7070        }
    71         ac.setConfigVars(this.config);
     71        ac.setConfigParams(this.config_params);
    7272        ac.setMessageRouter(this.mr);
    7373        ac.configure();
     
    8686       
    8787        String map_key = action_name+":"+subname;
    88         System.out.println("adding in to xslt map, "+map_key+"->"+subxslt);
     88        ///ystem.out.println("adding in to xslt map, "+map_key+"->"+subxslt);
    8989        this.xslt_map.put(map_key, subxslt);
    9090        }
     
    9292       
    9393    }
    94 
     94   
    9595    return true;
    9696    }
     
    107107    }
    108108   
    109     /** adds in the config stuff and interface display stuff -
    110      * needed by the xslt
    111      */
    112     protected void addExtraInfo(Element page) {
    113     Element page_extra = this.doc.createElement(GSXML.PAGE_EXTRA_ELEM);
    114     page.appendChild(page_extra);
    115     String lang = ((Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM)).getAttribute(GSXML.LANG_ATT);
    116     Element display = getDisplayElement(lang);
    117     page_extra.appendChild(this.doc.importNode(display, true));
    118     page_extra.appendChild(this.doc.importNode(this.config.config_xml_, true));
    119    
    120     return;
    121     }
     109    /** overwrite this to add any extra info that might be needed in the page before transformation */
     110    protected void addExtraInfo(Element page) {}
    122111
    123     /** transform teh page using xslt
    124      * we need to get any format element out of teh page and add it to the xslt
     112    /** transform the page using xslt
     113     * we need to get any format element out of the page and add it to the xslt
    125114     * before transforming */
    126115    protected Element transformPage(Element page) {
     
    144133       
    145134        // need to transform the format info
    146         String stylesheet_file = GSFile.stylesheetFile(this.config, "config_format.xsl");
     135        String stylesheet_file = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), "config_format.xsl");
    147136        Document stylesheet = this.converter.getDOM(new File(stylesheet_file));
    148         Element new_format = (Element)this.transformer.transform(stylesheet, format_elem);
     137        Document format_doc = this.converter.newDOM();
     138        format_doc.appendChild(format_doc.importNode(format_elem, true));
     139        Element new_format = (Element)this.transformer.transform(stylesheet, format_doc);
    149140        // add it in to the main stylesheet
    150141        GSXSLT.mergeStylesheets(style_doc, new_format);
    151         //System.out.println("the converted stylesheet is:");
    152         //System.out.println(this.converter.getPrettyString(style_doc.getDocumentElement()));
     142        ///ystem.out.println("the converted stylesheet is:");
     143        ///ystem.out.println(this.converter.getPrettyString(style_doc.getDocumentElement()));
    153144    }
    154145   
    155     GSXSLT.absoluteIncludePaths(style_doc, this.config);
    156     return (Element)this.transformer.transform(style_doc, page);         
     146    // there is a thing called a URIResolver which you can set for a transformer or transformer factory. may be able to use this instead of this absoluteIncludepaths hack
     147    GSXSLT.absoluteIncludePaths(style_doc, (String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME));
     148    // put the page into a document - this is necessary for xslt to get the paths right if you have paths relative to the document root eg /page.
     149    Document doc = this.converter.newDOM();
     150    doc.appendChild(doc.importNode(page, true));
     151    return (Element)this.transformer.transform(style_doc, doc, config_params);         
    157152    }
    158153
     
    169164    }
    170165    // now find the absolute path
    171     String stylesheet = GSFile.stylesheetFile(this.config, name);
     166    String stylesheet = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), (String)this.config_params.get(GSConstants.INTERFACE_NAME), name);
    172167    if (stylesheet==null) {
    173168        System.out.println("cant find stylesheet for "+name);
     
    183178    Element display = this.doc.createElement(GSXML.DISPLAY_ELEM);
    184179    // looks for properties files based on interface name
    185     String resource_name = "interface_"+this.config.interface_name_;
     180    String resource_name = "interface_"+ (String)this.config_params.get(GSConstants.INTERFACE_NAME);
    186181
    187182    Dictionary dict = new Dictionary(resource_name, lang);
Note: See TracChangeset for help on using the changeset viewer.