Changeset 8562
- Timestamp:
- 2004-11-16T12:22:43+13:00 (19 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java
r5402 r8562 13 13 import java.util.HashMap; 14 14 import java.util.Enumeration; 15 import java.util.ArrayList; 15 16 16 17 /** the most basic Receptionist, used for interface generation. … … 40 41 protected Element language_list = null; 41 42 43 /** the list of interfaces this is based on */ 44 protected ArrayList base_interfaces = null; 45 42 46 public Receptionist() { 43 47 this.converter = new XMLConverter(); … … 78 82 79 83 Element config_doc = this.converter.getDOM(interface_config_file).getDocumentElement(); 84 String base_interface = config_doc.getAttribute("baseInterface"); 85 setUpBaseInterface(base_interface); 80 86 Element action_list = (Element)GSXML.getChildByTagName(config_doc, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER); 81 87 NodeList actions = action_list.getElementsByTagName(GSXML.ACTION_ELEM); … … 193 199 page.appendChild(page_response); 194 200 195 ///ystem.out.println("R Eceptionist: raw page="+this.converter.getString(page));201 ///ystem.out.println("Receptionist: raw page="+this.converter.getString(page)); 196 202 // transform the result in some way 197 203 Element resulting_page = postProcessPage(page); … … 200 206 } 201 207 208 protected boolean setUpBaseInterface(String base_interface) { 209 if (base_interface== null || base_interface.equals("")) { 210 // there was no base interface, the list remains null 211 return true; 212 } 213 // foreach base interface 214 while (!base_interface.equals("")) { 215 // find the base interface config file 216 File base_interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome((String)this.config_params.get(GSConstants.GSDL3_HOME), base_interface))); 217 if (!base_interface_config_file.exists()) { 218 System.err.println("Receptionist: base interface config file: "+base_interface_config_file.getPath()+" not found!"); 219 return false; 220 } 221 // the interface name is valid, add it to the list 222 if (base_interfaces == null) { 223 base_interfaces = new ArrayList(); 224 } 225 base_interfaces.add(base_interface); 226 // now see if this has a base interface 227 Element config_doc = this.converter.getDOM(base_interface_config_file).getDocumentElement(); 228 base_interface = config_doc.getAttribute("baseInterface"); 229 } 230 return true; 231 } 202 232 protected void preProcessRequest(Element request) { 203 233 return; -
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r5693 r8562 54 54 55 55 Element config_doc = this.converter.getDOM(interface_config_file, "utf-8").getDocumentElement(); 56 String base_interface = config_doc.getAttribute("baseInterface"); 57 setUpBaseInterface(base_interface); 56 58 Element action_list = (Element)GSXML.getChildByTagName(config_doc, GSXML.ACTION_ELEM+GSXML.LIST_MODIFIER); 57 59 NodeList actions = action_list.getElementsByTagName(GSXML.ACTION_ELEM); … … 122 124 protected Element transformPage(Element page) { 123 125 126 //ystem.out.println("page before transfomring:"); 127 //ystem.out.println(this.converter.getPrettyString(page)); 128 124 129 Element request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM); 125 130 String action = request.getAttribute("action"); … … 147 152 if (format_elem != null) { 148 153 //page_response.removeChild(format_elem); 149 154 ///ystem.err.println("format elem="+this.converter.getPrettyString(format_elem)); 150 155 // need to transform the format info 151 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");156 String stylesheet_file = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, "config_format.xsl"); 152 157 Document stylesheet = this.converter.getDOM(new File(stylesheet_file)); 153 158 Document format_doc = this.converter.newDOM(); 154 159 format_doc.appendChild(format_doc.importNode(format_elem, true)); 155 160 Element new_format = (Element)this.transformer.transform(stylesheet, format_doc); 161 ///ystem.err.println("new format elem="+this.converter.getPrettyString(new_format)); 162 156 163 // add it in to the main stylesheet 157 164 GSXSLT.mergeStylesheets(style_doc, new_format); … … 161 168 162 169 // 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 163 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), collection);170 GSXSLT.absoluteIncludePaths(style_doc, (String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces); 164 171 // 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. 165 172 Document doc = this.converter.newDOM(); … … 181 188 } 182 189 // now find the absolute path 183 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), collection, name);190 String stylesheet = GSFile.stylesheetFile((String)this.config_params.get(GSConstants.GSDL3_HOME), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name); 184 191 if (stylesheet==null) { 185 192 System.out.println("TransformingReceptionist: cant find stylesheet for "+name); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java
r6893 r8562 29 29 import java.lang.ClassLoader; // to find files on the class path 30 30 import java.net.URL; 31 import java.util.ArrayList; 31 32 32 33 /** … … 210 211 211 212 /** returns the absolute path to a stylesheet 212 * stylesheets are looked for in the following order213 * collect-specific,214 * site-specific, interface-specific, default213 * stylesheets are looked for in the following places, in the 214 * following order: 215 * current collection, current site, current interface, base interfaces 215 216 * returns null if the file cannot be found 216 217 * … … 218 219 static public String stylesheetFile(String gsdl3_home, 219 220 String site_name, 221 String collection, 220 222 String interface_name, 221 String collection,223 ArrayList base_interfaces, 222 224 String filename) { 223 225 … … 234 236 } 235 237 } 236 // try site one next237 238 239 // try site one next 238 240 stylesheet = new File(site_home +File.separatorChar+ 239 241 "transform"+File.separatorChar+filename); 240 242 if (stylesheet.exists()) { 241 243 return stylesheet.getPath(); 242 244 } 245 243 246 // try current interface 244 247 String interface_home = interfaceHome(gsdl3_home, … … 249 252 return stylesheet.getPath(); 250 253 } 251 // try default interface 252 interface_home = interfaceHome(gsdl3_home, "default"); 253 stylesheet = new File(interface_home+File.separatorChar+ 254 "transform"+File.separatorChar+filename); 255 if (stylesheet.exists()) { 256 return stylesheet.getPath(); 254 // try base interface 255 if (base_interfaces==null || base_interfaces.size()==0) { 256 return null; // no base interfaces to look for 257 } 258 for (int i=0; i<base_interfaces.size(); i++) { 259 interface_home = interfaceHome(gsdl3_home, (String)base_interfaces.get(i)); 260 stylesheet = new File(interface_home+File.separatorChar+ 261 "transform"+File.separatorChar+filename); 262 if (stylesheet.exists()) { 263 return stylesheet.getPath(); 264 } 257 265 } 258 266 259 // cant find it267 // still can't find it and we have looked everywhere 260 268 return null; 261 269 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r4860 r8562 9 9 import java.util.HashMap; 10 10 import java.util.Vector; 11 import java.util.ArrayList; 11 12 12 13 /** various functions for manipulating Greenstone xslt */ … … 42 43 String gsdl3_home, 43 44 String site_name, 45 String collection, 44 46 String interface_name, 45 String collection) {47 ArrayList base_interfaces) { 46 48 47 49 … … 51 53 String name = child.getNodeName(); 52 54 if (name.equals("xsl:import") || name.equals("xsl:include")) { 53 ((Element)child).setAttribute("href", GSFile.stylesheetFile(gsdl3_home, site_name, interface_name, collection, ((Element)child).getAttribute("href")));55 ((Element)child).setAttribute("href", GSFile.stylesheetFile(gsdl3_home, site_name, collection, interface_name, base_interfaces, ((Element)child).getAttribute("href"))); 54 56 } 55 57 child = child.getNextSibling();
Note:
See TracChangeset
for help on using the changeset viewer.