Changeset 24703
- Timestamp:
- 2011-09-30T15:10:57+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r24583 r24703 28 28 import javax.xml.transform.stream.*; 29 29 import org.apache.log4j.*; 30 import org.apache.tools.zip.ExtraFieldUtils; 30 31 import org.apache.xerces.dom.*; 31 32 import org.apache.xerces.parsers.DOMParser; … … 754 755 //System.out.println("Generate final HTML from current skin") ; 755 756 //Transformation of the XML message from the receptionist to HTML with doctype 756 757 758 if(skinAndLibraryDoc.getElementsByTagName("gsf:metadata").getLength() > 0) 759 { 760 secondConfigFormatPass(collection, skinAndLibraryDoc, doc, request.getAttribute("lang"), request.getAttribute("uid")); 761 } 762 763 if (output.equals("xmlfinal")) 764 { 765 return doc; 766 } 767 757 768 return this.transformer.transform(skinAndLibraryDoc, doc, config_params, docWithDoctype); // The default 758 769 … … 762 773 //return (Element)this.transformer.transform(style_doc, doc, config_params); 763 774 //return null; // For now - change later 775 } 776 777 protected void secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, String lang, String uid) 778 { 779 String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired? 780 Element metaMessage = this.doc.createElement(GSXML.MESSAGE_ELEM); 781 Element metaRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, lang, uid); 782 Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 783 Element docNodeList = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER); 784 785 NodeList metaNodes = skinAndLibraryDoc.getElementsByTagName("gsf:metadata"); 786 787 for(int i = 0; i < metaNodes.getLength(); i++) 788 { 789 Element param = this.doc.createElement(GSXML.PARAM_ELEM); 790 param.setAttribute(GSXML.NAME_ATT, "metadata"); 791 param.setAttribute(GSXML.VALUE_ATT, ((Element)metaNodes.item(i)).getAttribute(GSXML.NAME_ATT)); 792 paramList.appendChild(param); 793 } 794 metaRequest.appendChild(paramList); 795 796 NodeList docNodes = doc.getElementsByTagName("documentNode"); 797 for(int i = 0; i < docNodes.getLength(); i++) 798 { 799 Element docNode = this.doc.createElement(GSXML.DOC_NODE_ELEM); 800 docNode.setAttribute(GSXML.NODE_ID_ATT, ((Element)docNodes.item(i)).getAttribute(GSXML.NODE_ID_ATT)); 801 docNode.setAttribute(GSXML.NODE_TYPE_ATT, ((Element)docNodes.item(i)).getAttribute(GSXML.NODE_TYPE_ATT)); 802 docNodeList.appendChild(docNode); 803 } 804 metaRequest.appendChild(docNodeList); 805 806 metaMessage.appendChild(metaRequest); 807 Element response = (Element)mr.process(metaMessage); 808 809 NodeList metaDocNodes = response.getElementsByTagName(GSXML.DOC_NODE_ELEM); 810 for(int i = 0; i < docNodes.getLength(); i++) 811 { 812 GSXML.mergeMetadataLists(docNodes.item(i), metaDocNodes.item(i)); 813 } 814 815 String configStylesheet_file = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, "config_format.xsl"); 816 Document configStylesheet_doc = this.converter.getDOM(new File(configStylesheet_file)); 817 818 if (configStylesheet_doc != null) 819 { 820 Document format_doc = this.converter.newDOM(); 821 format_doc.appendChild(format_doc.importNode(skinAndLibraryDoc.getDocumentElement().cloneNode(true), true)); 822 Node result = this.transformer.transform(configStylesheet_doc, format_doc, config_params); 823 GSXSLT.mergeStylesheets(skinAndLibraryDoc, ((Document)result).getDocumentElement()); 824 } 764 825 } 765 826
Note:
See TracChangeset
for help on using the changeset viewer.