Changeset 25987
- Timestamp:
- 2012-07-19T15:07:02+12:00 (11 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r25912 r25987 739 739 } 740 740 741 GSXSLT.inlineImportAndIncludeFiles(skinAndLibraryDoc, null );741 GSXSLT.inlineImportAndIncludeFiles(skinAndLibraryDoc, null, (String) this.config_params.get(GSConstants.INTERFACE_NAME)); 742 742 skinAndLibraryDoc = (Document) secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request)); 743 743 … … 864 864 name = this.xslt_map.get(action); 865 865 } 866 // now find the absolute path 867 ArrayList<File> stylesheets = GSFile.getStylesheetFiles(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name); 868 if (stylesheets.size() == 0) 869 { 870 logger.error(" Can't find stylesheet for " + name); 871 return null; 872 } 873 logger.debug("Stylesheet: " + name); 874 875 Document finalDoc = this.converter.getDOM(stylesheets.get(stylesheets.size() - 1), "UTF-8"); 876 if (finalDoc == null) 877 { 878 return null; 879 } 880 881 for (int i = stylesheets.size() - 2; i >= 0; i--) 882 { 883 Document currentDoc = this.converter.getDOM(stylesheets.get(i), "UTF-8"); 884 if (currentDoc == null) 885 { 886 return null; 887 } 888 889 if (_debug) 890 { 891 GSXSLT.mergeStylesheetsDebug(finalDoc, currentDoc.getDocumentElement(), true, true, stylesheets.get(stylesheets.size() - 1).getAbsolutePath(), stylesheets.get(i).getAbsolutePath()); 892 } 893 else 894 { 895 GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true); 896 } 897 } 898 866 867 Document finalDoc = GSXSLT.mergedXSLTDocumentCascade(name, (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, _debug); 899 868 return finalDoc; 900 869 } 870 // // now find the absolute path 871 // ArrayList<File> stylesheets = GSFile.getStylesheetFiles(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name); 872 // if (stylesheets.size() == 0) 873 // { 874 // logger.error(" Can't find stylesheet for " + name); 875 // return null; 876 // } 877 // logger.debug("Stylesheet: " + name); 878 879 // Document finalDoc = this.converter.getDOM(stylesheets.get(stylesheets.size() - 1), "UTF-8"); 880 // if (finalDoc == null) 881 // { 882 // return null; 883 // } 884 885 // for (int i = stylesheets.size() - 2; i >= 0; i--) 886 // { 887 // Document currentDoc = this.converter.getDOM(stylesheets.get(i), "UTF-8"); 888 // if (currentDoc == null) 889 // { 890 // return null; 891 // } 892 893 // if (_debug) 894 // { 895 // GSXSLT.mergeStylesheetsDebug(finalDoc, currentDoc.getDocumentElement(), true, true, stylesheets.get(stylesheets.size() - 1).getAbsolutePath(), stylesheets.get(i).getAbsolutePath()); 896 // } 897 // else 898 // { 899 // GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true); 900 // } 901 // } 902 903 // return finalDoc; 904 // } 901 905 902 906 // returns the path to the gslib.xsl file that is applicable for the current interface -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r25982 r25987 29 29 import org.w3c.dom.NodeList; 30 30 31 import org.apache.log4j.*; 32 31 33 /** various functions for manipulating Greenstone xslt */ 32 34 public class GSXSLT 33 35 { 36 37 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.GSXSLT.class.getName()); 38 34 39 public static void mergeStylesheets(Document main_xsl, Element extra_xsl, boolean overwrite) 35 40 { … … 215 220 } 216 221 217 public static void inlineImportAndIncludeFiles(Document doc, String pathExtra)218 { 219 inlineImportAndIncludeFilesDebug(doc, pathExtra, false, null);220 } 221 222 public static void inlineImportAndIncludeFilesDebug(Document doc, String pathExtra, boolean debug, String docFileName)222 public static void inlineImportAndIncludeFiles(Document doc, String pathExtra, String interface_name) 223 { 224 inlineImportAndIncludeFilesDebug(doc, pathExtra, false, null, interface_name); 225 } 226 227 public static void inlineImportAndIncludeFilesDebug(Document doc, String pathExtra, boolean debug, String docFileName, String interface_name) 223 228 { 224 229 XMLConverter converter = new XMLConverter(); … … 233 238 Element current = (Element) ((i < importList.getLength()) ? importList.item(i) : includeList.item(i - importList.getLength())); 234 239 String href = current.getAttribute("href"); 235 String filePath = GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), "default") + File.separator + "transform" + File.separator + path.replace("/", File.separator) + href.replace("/", File.separator); 240 String filePath = GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), interface_name) + File.separator + "transform" + File.separator + path.replace("/", File.separator) + href.replace("/", File.separator); 241 //String filePath = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), site_name, collection, interface_name, base_interfaces, 236 242 237 243 try … … 247 253 248 254 //Do this recursively 249 inlineImportAndIncludeFilesDebug(inlineDoc, newPath, debug, filePath );255 inlineImportAndIncludeFilesDebug(inlineDoc, newPath, debug, filePath, interface_name); 250 256 251 257 GSXSLT.mergeStylesheetsDebug(doc, inlineDoc.getDocumentElement(), false, debug, docFileName, filePath); … … 269 275 } 270 276 } 277 278 public static Document mergedXSLTDocumentCascade(String xslt_filename, String site, String collection, String this_interface, ArrayList<String> base_interfaces, boolean debug) { 279 XMLConverter converter = new XMLConverter(); 280 // find the list of stylesheets with this name 281 ArrayList<File> stylesheets = GSFile.getStylesheetFiles(GlobalProperties.getGSDL3Home(), site, collection, this_interface, base_interfaces, xslt_filename); 282 if (stylesheets.size() == 0) 283 { 284 logger.error(" Can't find stylesheet for " + xslt_filename); 285 return null; 286 } 287 logger.debug("Stylesheet: " + xslt_filename); 288 289 Document finalDoc = converter.getDOM(stylesheets.get(stylesheets.size() - 1), "UTF-8"); 290 if (finalDoc == null) 291 { 292 return null; 293 } 294 295 for (int i = stylesheets.size() - 2; i >= 0; i--) 296 { 297 Document currentDoc = converter.getDOM(stylesheets.get(i), "UTF-8"); 298 if (currentDoc == null) 299 { 300 return null; 301 } 302 303 if (debug) 304 { 305 GSXSLT.mergeStylesheetsDebug(finalDoc, currentDoc.getDocumentElement(), true, true, stylesheets.get(stylesheets.size() - 1).getAbsolutePath(), stylesheets.get(i).getAbsolutePath()); 306 } 307 else 308 { 309 GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true); 310 } 311 } 312 313 return finalDoc; 314 } 315 316 271 317 272 318 public static void modifyConfigFormatForDebug(Document doc, String fileName)
Note:
See TracChangeset
for help on using the changeset viewer.