Changeset 25912
- Timestamp:
- 2012-07-10T10:18:38+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r25872 r25912 92 92 e.printStackTrace(); 93 93 } 94 95 94 } 96 95 … … 559 558 //for debug purposes only 560 559 Document oldStyle_doc = style_doc; 561 562 560 Document preprocessingXsl; 563 561 try … … 641 639 } 642 640 643 //The following code is to be uncommented if we need to append the extracted GSF statements644 //after having extracted the GSLib elements. In case of a problem during postprocessing.645 /*646 * // put the page into a document - this is necessary for xslt to get647 * // the paths right if you have paths relative to the document root //648 * eg /page. Document doc = this.converter.newDOM();649 * doc.appendChild(doc.importNode(page, true)); Element page_response =650 * (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);651 * Element format_elem = (Element)GSXML.getChildByTagName(page_response,652 * GSXML.FORMAT_ELEM); if (output.equals("formatelem")) { return653 * format_elem; } if (format_elem != null) {654 * //page_response.removeChild(format_elem);655 * logger.debug("format elem="+656 * this.converter.getPrettyString(format_elem)); // need to transform657 * the format info String configStylesheet_file =658 * GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(),659 * (String)this.config_params.get(GSConstants.SITE_NAME), collection,660 * (String)this.config_params.get(GSConstants.INTERFACE_NAME),661 * base_interfaces, "config_format.xsl"); Document configStylesheet_doc662 * = this.converter.getDOM(new File(configStylesheet_file)); if663 * (configStylesheet_doc != null) { Document format_doc =664 * this.converter.newDOM();665 * format_doc.appendChild(format_doc.importNode(format_elem, true));666 * Node result = this.transformer.transform(configStylesheet_doc,667 * format_doc);668 *669 * // Since we started creating documents with DocTypes, we can end up670 * with // Document objects here. But we will be working with an Element671 * instead, // so we grab the DocumentElement() of the Document object672 * in such a case. Element new_format; if(result.getNodeType() ==673 * Node.DOCUMENT_NODE) { new_format =674 * ((Document)result).getDocumentElement(); } else { new_format =675 * (Element)result; }676 * logger.debug("new format elem="+this.converter.getPrettyString677 * (new_format)); if (output.equals("newformat")) { return new_format; }678 *679 * // add extracted GSF statements in to the main stylesheet680 * GSXSLT.mergeStylesheets(skinAndLibraryDoc, new_format);681 * //System.out.println682 * ("added extracted GSF statements into the main stylesheet") ;683 *684 * // add extracted GSF statements in to the debug test stylesheet685 * //GSXSLT.mergeStylesheets(oldStyle_doc, new_format); } else {686 * logger.error(687 * " couldn't parse the config_format stylesheet, adding the format info as is"688 * ); GSXSLT.mergeStylesheets(skinAndLibraryDoc, format_elem); //689 * GSXSLT.mergeStylesheets(oldStyle_doc, format_elem); }690 * logger.debug("the converted stylesheet is:");691 * logger.debug(this.converter692 * .getPrettyString(skinAndLibraryDoc.getDocumentElement())); }693 */694 695 641 // there is a thing called a URIResolver which you can set for a 696 642 // transformer or transformer factory. may be able to use this 697 643 // instead of this absoluteIncludepaths hack 698 644 699 GSXSLT.absoluteIncludePaths(skinAndLibraryDoc, GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces);645 //GSXSLT.absoluteIncludePaths(skinAndLibraryDoc, GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces); 700 646 701 647 //Same but for the debug version when we want the do the transformation like we use to do … … 793 739 } 794 740 795 if (skinAndLibraryDoc.getElementsByTagName("gsf:metadata").getLength() > 0) 796 { 797 secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request)); 741 GSXSLT.inlineImportAndIncludeFiles(skinAndLibraryDoc, null); 742 skinAndLibraryDoc = (Document) secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request)); 743 744 if (_debug) 745 { 746 GSXML.addDebugSpanTags(skinAndLibraryDoc); 798 747 } 799 748 … … 803 752 } 804 753 805 if (_debug)806 {807 GSXML.addDebugSpanTags(skinAndLibraryDoc);808 }809 754 if (output.equals("skinandlibdocfinal")) 810 755 { 811 756 return converter.getDOM(getStringFromDocument(skinAndLibraryDoc)); 812 757 } 758 813 759 return this.transformer.transform(skinAndLibraryDoc, doc, config_params, docWithDoctype); 814 760 … … 820 766 } 821 767 822 protected voidsecondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, UserContext userContext)768 protected Node secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, UserContext userContext) 823 769 { 824 770 String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired? … … 863 809 if (configStylesheet_doc != null) 864 810 { 865 Document format_doc = XMLConverter.newDOM(); 866 format_doc.appendChild(format_doc.importNode(skinAndLibraryDoc.getDocumentElement().cloneNode(true), true)); 867 Node result = this.transformer.transform(configStylesheet_doc, format_doc, config_params); 868 if (_debug) 869 { 870 GSXSLT.mergeStylesheetsDebug(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true, true, "OTHER3", GSFile.collectionConfigFile(GSFile.collectDir(GSFile.siteHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME)) + File.separator + collection))); 871 } 872 else 873 { 874 GSXSLT.mergeStylesheets(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true); 875 // we just want the result of the transform to be in skinAndLibraryDoc 876 Element old_doc = skinAndLibraryDoc.getDocumentElement(); 877 skinAndLibraryDoc.removeChild(old_doc); 878 skinAndLibraryDoc.appendChild(skinAndLibraryDoc.importNode(((Document) result).getDocumentElement(), true)); 879 } 880 } 811 return this.transformer.transform(configStylesheet_doc, skinAndLibraryDoc, config_params); 812 } 813 return skinAndLibraryDoc; 881 814 } 882 815 … … 933 866 // now find the absolute path 934 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); 935 936 868 if (stylesheets.size() == 0) 937 869 { … … 963 895 GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true); 964 896 } 965 }966 967 if (_debug)968 {969 GSXSLT.inlineImportAndIncludeFiles(finalDoc, null, 0);970 897 } 971 898
Note:
See TracChangeset
for help on using the changeset viewer.