Changeset 4691
- Timestamp:
- 2003-06-18T11:37:07+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r4286 r4691 37 37 public boolean configure() { 38 38 39 if (this.config ==null) {39 if (this.config_params==null) { 40 40 System.err.println("Receptionist Error: config variables must be set before calling configure"); 41 41 return false; … … 47 47 48 48 // 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)))); 50 50 if (!interface_config_file.exists()) { 51 51 System.err.println("TransformingReceptionist: interface config file: "+interface_config_file.getPath()+" not found!"); … … 65 65 ac = (Action)Class.forName("org.greenstone.gsdl3.action."+class_name).newInstance(); 66 66 } 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); 68 68 e.printStackTrace(); 69 69 continue; 70 70 } 71 ac.setConfig Vars(this.config);71 ac.setConfigParams(this.config_params); 72 72 ac.setMessageRouter(this.mr); 73 73 ac.configure(); … … 86 86 87 87 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); 89 89 this.xslt_map.put(map_key, subxslt); 90 90 } … … 92 92 93 93 } 94 94 95 95 return true; 96 96 } … … 107 107 } 108 108 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) {} 122 111 123 /** transform t ehpage using xslt124 * we need to get any format element out of t ehpage and add it to the xslt112 /** transform the page using xslt 113 * we need to get any format element out of the page and add it to the xslt 125 114 * before transforming */ 126 115 protected Element transformPage(Element page) { … … 144 133 145 134 // 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"); 147 136 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); 149 140 // add it in to the main stylesheet 150 141 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())); 153 144 } 154 145 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); 157 152 } 158 153 … … 169 164 } 170 165 // 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); 172 167 if (stylesheet==null) { 173 168 System.out.println("cant find stylesheet for "+name); … … 183 178 Element display = this.doc.createElement(GSXML.DISPLAY_ELEM); 184 179 // 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); 186 181 187 182 Dictionary dict = new Dictionary(resource_name, lang);
Note:
See TracChangeset
for help on using the changeset viewer.