- Timestamp:
- 2014-05-08T15:38:11+12:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/recpt/formattools.cpp
r28960 r29042 59 59 ostream &logout); 60 60 61 static text_t transform_to_GS3_format (format_t *formatlistptr );61 static text_t transform_to_GS3_format (format_t *formatlistptr, const text_t& nodeType); 62 62 63 63 void metadata_t::clear() { … … 2154 2154 } 2155 2155 2156 static text_t get_gs3_if (const decision_t &decision, format_t *ifptr, format_t *elseptr )2156 static text_t get_gs3_if (const decision_t &decision, format_t *ifptr, format_t *elseptr, const text_t& nodeType) 2157 2157 { 2158 2158 text_t ifstmt ="<gsf:switch>"; … … 2215 2215 text_t if_body = ""; 2216 2216 while(ifptr != NULL) { // body of if can contain a list of items to be transformed into GS3 format stmts 2217 if_body += transform_to_GS3_format (ifptr );2217 if_body += transform_to_GS3_format (ifptr, nodeType); 2218 2218 ifptr = ifptr->nextptr; 2219 2219 } … … 2227 2227 text_t else_body = ""; // body of else can contain a list of items to be transformed into GS3 format stmts 2228 2228 while(elseptr != NULL) { 2229 else_body += transform_to_GS3_format (elseptr );2229 else_body += transform_to_GS3_format (elseptr, nodeType); 2230 2230 elseptr = elseptr->nextptr; 2231 2231 } … … 2239 2239 2240 2240 2241 static text_t get_gs3_or (format_t *orptr ) {2241 static text_t get_gs3_or (format_t *orptr, const text_t& nodeType) { 2242 2242 text_t result = "<gsf:choose-metadata>"; 2243 2243 2244 2244 while(orptr != NULL) { 2245 text_t or_body = transform_to_GS3_format (orptr );2245 text_t or_body = transform_to_GS3_format (orptr, nodeType); 2246 2246 if (!or_body.empty()) { 2247 2247 result += or_body; … … 2255 2255 2256 2256 // what about all the <td>? Does that get stored in formatlistptr, such as under the ->text field? 2257 text_t get_GS3_formatstring (format_t *formatlistptr ) {2257 text_t get_GS3_formatstring (format_t *formatlistptr, const text_t& nodeType) { 2258 2258 text_t result; 2259 2259 2260 2260 while (formatlistptr != NULL) { 2261 result += transform_to_GS3_format(formatlistptr );2261 result += transform_to_GS3_format(formatlistptr, nodeType); 2262 2262 formatlistptr = formatlistptr->nextptr; 2263 2263 } … … 2266 2266 } 2267 2267 2268 text_t transform_to_GS3_format (format_t *formatlistptr) { 2269 2268 text_t transform_to_GS3_format (format_t *formatlistptr, const text_t& nodeType) { 2270 2269 if (formatlistptr == NULL) return ""; 2271 2270 … … 2280 2279 return formatlistptr->text; // [text]? or any string that is not a command or reserved 2281 2280 case comLink: 2282 return "<gsf:link type='document'>"; // type? 2281 if(nodeType == "classifier") { 2282 return "<gsf:link type='classifier'>"; 2283 } else { // if nodeType is document or not set 2284 return "<gsf:link type='document'>"; 2285 } 2283 2286 case comEndLink: 2284 2287 return "</gsf:link>"; … … 2286 2289 return "<gsf:lib name=\"href\"/>"; // ??? in gslib xsl, output comment marking not sure what this maps to 2287 2290 case comIcon: 2288 return "<gsf:icon type='document'/>"; 2291 if(nodeType == "classifier") { 2292 return "<gsf:icon type='classifier'/>"; 2293 } else { // if nodeType is document or not set 2294 return "<gsf:icon type='document'/>"; 2295 } 2289 2296 case comNum: 2290 2297 return "<gsf:lib name=\"num\"/>"; // ??? in gslib xsl, output comment marking not sure what this maps to … … 2335 2342 break; 2336 2343 case comIf: 2337 return get_gs3_if (formatlistptr->decision, formatlistptr->ifptr, formatlistptr->elseptr); 2344 if(formatlistptr->decision.meta.metaname == "numleafdocs") { 2345 if(nodeType == "classifier") { 2346 text_t if_body = ""; 2347 while(formatlistptr->ifptr != NULL) { // body of if can contain a list of items to be transformed into GS3 format stmts 2348 if_body += transform_to_GS3_format (formatlistptr->ifptr, nodeType); 2349 formatlistptr->ifptr = formatlistptr->ifptr->nextptr; 2350 } 2351 return if_body; 2352 } else if(nodeType == "document") { 2353 text_t else_body = ""; // body of else can contain a list of items to be transformed into GS3 format stmts 2354 while(formatlistptr->elseptr != NULL) { 2355 else_body += transform_to_GS3_format (formatlistptr->elseptr, nodeType); 2356 formatlistptr->elseptr = formatlistptr->elseptr->nextptr; 2357 } 2358 return else_body; 2359 } 2360 } 2361 2362 // if nodeType not specified as classifier or document, or if the If test is not for numleafdocs' existence 2363 return get_gs3_if (formatlistptr->decision, formatlistptr->ifptr, formatlistptr->elseptr, nodeType); 2338 2364 case comOr: 2339 return get_gs3_or (formatlistptr->orptr );2340 //return "<gsf:choose-metadata>"+get_gs3_or (formatlistptr->orptr )+"</gsf:choose-metadata>";2365 return get_gs3_or (formatlistptr->orptr, nodeType); 2366 //return "<gsf:choose-metadata>"+get_gs3_or (formatlistptr->orptr, nodeType)+"</gsf:choose-metadata>"; 2341 2367 case comDocTermsFreqTotal: 2342 2368 return "<gsf:lib name=\"DocTermsFreqTotal\"/>";
Note:
See TracChangeset
for help on using the changeset viewer.