Changeset 3863 for trunk/gsdl3/src/java/org/greenstone/gsdl3/action
- Timestamp:
- 2003-03-12T15:05:08+13:00 (21 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/action
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
r3817 r3863 77 77 ds_param.setAttribute(GSXML.VALUE_ATT, "children"); 78 78 79 // Create a content section to store the list of documents we are interested in 80 Element ds_content = doc_.createElement(GSXML.CONTENT_ELEM); 81 ds_request.appendChild(ds_content); 82 Element ds_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 83 ds_content.appendChild(ds_doc_list); 84 Element ds_doc = doc_.createElement(GSXML.DOCUMENT_ELEM); 79 // create a doc_node_list and put in the doc_node that we are interested in 80 Element ds_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 81 ds_request.appendChild(ds_doc_list); 82 Element ds_doc = doc_.createElement(GSXML.DOC_NODE_ELEM); 85 83 ds_doc_list.appendChild(ds_doc); 86 ds_doc.setAttribute(GSXML. NAME_ATT, document_name);87 84 ds_doc.setAttribute(GSXML.DOC_NODE_ID_ATT, document_name); 85 88 86 // Process the document structure retrieve message 89 87 // System.out.println("(DocumentAction) Structure request:\n" + converter_.getString(ds_message)); 90 Element ds_response = (Element) mr_.process(ds_message); 91 // System.out.println("(DocumentAction) Structure response:\n" + converter_.getString(ds_response)); 92 93 Element ds_response_content = (Element) GSXML.getNodeByPath(ds_response, "response/content"); 94 Element ds_response_doc_list = (Element) GSXML.getNodeByPath(ds_response_content, "documentList"); 95 Element ds_response_document = (Element) GSXML.getNodeByPath(ds_response_doc_list, "document"); 88 Element ds_response_message = (Element) mr_.process(ds_message); 89 // System.out.println("(DocumentAction) Structure response:\n" + converter_.getString(ds_response_message)); 90 91 // get the doc_node bit 92 String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 93 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM); 94 path = GSPath.appendLink(path, GSXML.DOC_NODE_STRUCTURE_ELEM); 95 Element ds_response_structure = (Element) GSXML.getNodeByPath(ds_response_message, path); 96 97 // the_document is where all the extra info is added into, to be returned in the page 98 Element the_document = doc_.createElement(GSXML.DOCUMENT_ELEM); 99 // add the contents of the structure bit into the_document 100 NodeList structs = ds_response_structure.getChildNodes(); 101 for (int i=0; i<structs.getLength();i++) { 102 the_document.appendChild(doc_.importNode(structs.item(i), true)); 103 } 104 //Element ds_response = (Element) GSXML.getChildByTagName(ds_response_message, GSXML.RESPONSE_ELEM); 105 //Element ds_response_doc_list = (Element) GSXML.getChildByTagName(ds_response, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 106 //Element ds_response_document = (Element) GSXML.getChildByTagName(ds_response_doc_list, GSXML.DOC_NODE_ELEM); 96 107 97 108 // Detach the document from the list, remove the list, and add the document back 98 ds_response_content.removeChild(ds_response_doc_list); 99 ds_response_content.appendChild(ds_response_document); 109 // ds_response is the re 110 //ds_response.removeChild(ds_response_doc_list); 111 //ds_response.appendChild(ds_response_document); 100 112 101 113 … … 110 122 111 123 // Create a parameter list to specify the required metadata information 124 // for now get Title 112 125 Element dm_param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 113 126 dm_request.appendChild(dm_param_list); … … 117 130 dm_param.setAttribute(GSXML.VALUE_ATT, "Title"); 118 131 119 // Create a content section to store the list of documents we are interested in 120 Element dm_content = doc_.createElement(GSXML.CONTENT_ELEM); 121 dm_request.appendChild(dm_content); 122 Element dm_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 123 dm_content.appendChild(dm_doc_list); 124 125 // Get the title metadata of the document nodes 126 NodeList doc_nodes = ds_response_document.getElementsByTagName(GSXML.DOC_NODE_ELEM); 132 // create the doc node list for the metadata request 133 Element dm_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 134 dm_request.appendChild(dm_doc_list); 135 136 // Add each node from the structure response into the metadata request 137 NodeList doc_nodes = the_document.getElementsByTagName(GSXML.DOC_NODE_ELEM); 127 138 for (int i = 0; i < doc_nodes.getLength(); i++) { 128 139 Element doc_node = (Element) doc_nodes.item(i); … … 138 149 139 150 // System.out.println("(DocumentAction) Metadata request:\n" + converter_.getString(dm_request)); 140 Element dm_response = (Element) mr_.process(dm_message);151 Element dm_response_message = (Element) mr_.process(dm_message); 141 152 // System.out.println("(DocumentAction) Metadata response:\n" + converter_.getString(dm_response)); 142 153 143 Element dm_response_content = (Element) GSXML.getNodeByPath(dm_response, "response/content"); 144 Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_content, "documentList"); 154 path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 155 Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_message, path); 156 157 //Element dm_response_content = (Element) GSXML.getNodeByPath(dm_response, "response/content"); 158 //Element dm_response_doc_list = (Element) GSXML.getNodeByPath(dm_response_content, "documentList"); 145 159 146 160 // Merge the metadata with the structure information … … 160 174 dc_request.setAttribute(GSXML.LANG_ATT, request.getAttribute(GSXML.LANG_ATT)); 161 175 162 // Create a parameter list to specify the request parameters 176 // Create a parameter list to specify the request parameters - empty for now 163 177 Element dc_param_list = doc_.createElement(GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 164 178 dc_request.appendChild(dc_param_list); 165 179 166 // Create a content section to store the list of documents we are interested in 167 Element dc_content = doc_.createElement(GSXML.CONTENT_ELEM); 168 dc_request.appendChild(dc_content); 169 Element dc_doc_list = doc_.createElement(GSXML.DOCUMENT_ELEM+GSXML.LIST_MODIFIER); 170 dc_content.appendChild(dc_doc_list); 171 Element dc_doc = doc_.createElement(GSXML.DOCUMENT_ELEM); 172 dc_doc_list.appendChild(dc_doc); 173 dc_doc.setAttribute(GSXML.NAME_ATT, document_name); 180 // the doc list for the content request is the same as the one for the structure request 181 dc_request.appendChild(ds_doc_list); 182 // Element dc_doc_list = doc_.createElement(GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 183 // dc_request.appendChild(dc_doc_list); 184 // Element dc_doc = doc_.createElement(GSXML.DOC_NODE_ELEM); 185 // dc_doc_list.appendChild(dc_doc); 186 // dc_doc.setAttribute(GSXML.DOC_NODE_ID, document_name); 174 187 175 188 // System.out.println("(DocumentAction) Content request:\n" + converter_.getString(dc_request)); 176 Element dc_response = (Element) mr_.process(dc_message);189 Element dc_response_message = (Element) mr_.process(dc_message); 177 190 // System.out.println("(DocumentAction) Content response:\n" + converter_.getString(dc_response)); 178 179 Element dc_response_doc_content = (Element) GSXML.getNodeByPath(dc_response, "response/content/documentList/document/content"); 191 192 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM); 193 path = GSPath.appendLink(path, GSXML.DOC_NODE_CONTENT_ELEM); 194 Element dc_response_doc_content = (Element) GSXML.getNodeByPath(dc_response_message, path); 180 195 181 196 // Merge the document content with the metadata and structure information … … 185 200 String dc_doc_id = doc_node_id.getNodeValue(); 186 201 if (dc_doc_id == document_name) { 187 doc_node.appendChild(d c_response_doc_content);202 doc_node.appendChild(doc_.importNode(dc_response_doc_content, true)); 188 203 break; 189 204 } 190 205 } 191 192 206 193 207 // Create the return page tree … … 203 217 Element response = doc_.createElement(GSXML.RESPONSE_ELEM); 204 218 page.appendChild(response); 205 response.appendChild( doc_.importNode(ds_response_content, true));206 219 response.appendChild(the_document); 220 207 221 // System.out.println("Finished page: " + converter_.getString(page)); 208 209 222 223 210 224 // Finally, process using the stylesheet, and return 211 225 String stylesheet = GSFile.stylesheetFile(config_, "document.xsl"); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java
r3802 r3863 166 166 // check that there are some documents - for now check the list, but later should use a numdocs metadata elem 167 167 path = GSXML.RESPONSE_ELEM; 168 path = GSPath.appendLink(path, GSXML.CONTENT_ELEM);169 path = GSPath.appendLink(path, GSXML.DOC UMENT_ELEM+GSXML.LIST_MODIFIER);168 //path = GSPath.appendLink(path, GSXML.CONTENT_ELEM); 169 path = GSPath.appendLink(path, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER); 170 170 171 171 Element document_list = (Element)GSXML.getNodeByPath(mr_query_response, … … 202 202 dm_param.setAttribute(GSXML.VALUE_ATT, "Title"); 203 203 204 Element meta_content = doc_.createElement(GSXML.CONTENT_ELEM);205 mr_metadata_request.appendChild(meta_content);204 //Element meta_content = doc_.createElement(GSXML.CONTENT_ELEM); 205 //mr_metadata_request.appendChild(meta_content); 206 206 207 207 // the first part of the content is the doc list 208 meta_content.appendChild(doc_.importNode(document_list, true));209 208 //meta_content.appendChild(doc_.importNode(document_list, true)); 209 mr_metadata_request.appendChild(doc_.importNode(document_list, true)); 210 210 // System.out.println("Metadata request: " + converter_.getString(mr_metadata_message)); 211 211 Element mr_metadata_response = (Element)mr_.process(mr_metadata_message); … … 219 219 // If there is some metadata about the query results, add it in 220 220 if (query_term_info_list != null) { 221 Element result_content = (Element) GSXML.getChildByTagName(result_response,222 GSXML.CONTENT_ELEM);223 result_ content.appendChild(query_term_info_list);221 //Element result_content = (Element) GSXML.getChildByTagName(result_response, GSXML.CONTENT_ELEM); 222 //result_content.appendChild(query_term_info_list); 223 result_response.appendChild(query_term_info_list); 224 224 } 225 225 226 226 page.appendChild(doc_.importNode(result_response, true)); 227 227 228 //System.out.println("XMLTransformer input: " + converter_.getString(page));228 System.out.println("XMLTransformer input: " + converter_.getString(page)); 229 229 230 230 // output the page
Note:
See TracChangeset
for help on using the changeset viewer.