source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/TEIRetrieve.java@ 30631

Last change on this file since 30631 was 28966, checked in by kjdon, 10 years ago

Lots of changes. Mainly to do with removing this.doc from everywhere. Document is not thread safe. Now we tend to create a new Document everytime we are starting a new page/message etc. in service this.desc_doc is available as teh document to create service info stuff. But it should only be used for this and not for other messages. newDOM is now static for XMLConverter. method param changes for some GSXML methods.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1package org.greenstone.gsdl3.service;
2
3
4// Greenstone classes
5import org.greenstone.gsdl3.util.*;
6
7// XML classes
8import org.w3c.dom.Document;
9import org.w3c.dom.Element;
10import org.w3c.dom.Node;
11import org.w3c.dom.Text;
12
13// General Java classes
14
15// just needs to override a few methods that are TEI specific
16public class TEIRetrieve extends XMLRetrieve {
17
18 protected Element extractTitleMeta(Document doc, Element section) {
19
20 Element meta_elem = doc.createElement(GSXML.METADATA_ELEM);
21 meta_elem.setAttribute(GSXML.NAME_ATT, "Title");
22
23 Element section_head = (Element)GSXML.getChildByTagName(section, "head");
24 if (section_head == null || !section_head.hasChildNodes()) {
25 // there is no head element, so take the type attribute and make that the title
26 String title = "("+section.getAttribute("type")+")";
27 Text t = doc.createTextNode(title);
28 meta_elem.appendChild(t);
29 } else {
30 // add the head element as the metadata content
31 meta_elem.appendChild(doc.importNode(section_head, true));
32 }
33 return meta_elem;
34 }
35
36 // this assumes that the scope refers to a top level node - this may be overwritten if the scope bit in the id is a shorthand of some sort
37 protected String translateScope(String scope) {
38 if (scope.equals("front")) {
39 return "text/front";
40 }
41 if (scope.equals("body")) {
42 return "text/body";
43 }
44 if (scope.equals("back")) {
45 return "text/back";
46 }
47 if (scope.equals("full")) { // is this ever used???
48 return "";
49 }
50 return scope;
51 }
52
53}
Note: See TracBrowser for help on using the repository browser.