Changeset 4079
- Timestamp:
- 2003-04-02T15:58:48+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r3450 r4079 8 8 9 9 import java.util.HashMap; 10 import java.util.Vector; 10 11 11 12 /** various functions for manipulating Greenstone xslt */ … … 43 44 44 45 } 46 47 /** 48 * looks through a stylesheet for <xxx:template match='template_name'> 49 * inside this template it looks for any <xxx:value-of select='metadataList/metadata[@name=yyy]> elements, and extracts the metadata names into a Vector 50 */ 51 public static Vector extractWantedMetadata(Document stylesheet, String template_name) { 52 53 Vector metadata = new Vector(); 54 Element base_node = stylesheet.getDocumentElement(); 55 NodeList templates = base_node.getElementsByTagNameNS("*","template"); 56 for (int i=0; i<templates.getLength(); i++) { 57 Element template = (Element)templates.item(i); 58 String match_name = template.getAttribute("match"); 59 if (!match_name.equals(template_name)) { 60 continue; // we're only looking for specific templates 61 } 62 String mode = template.getAttribute("mode"); 63 if (!mode.equals("")) { 64 continue; // we only want ones without modes - these are processing ones, not display ones 65 } 66 // we have one that we want to look through 67 NodeList values = template.getElementsByTagNameNS("*", "value-of"); 68 for (int v=0; v<values.getLength(); v++) { 69 String select = ((Element)values.item(v)).getAttribute("select"); 70 if (select.startsWith("metadataList/metadata[@name=")) { 71 String []bits = select.split("'|\""); 72 // there should be two quotes in teh string, therefore 3 items, and the second one is teh one we want 73 String name = bits[1]; 74 metadata.add(name); 75 } 76 } 77 } 78 return metadata; 79 } 80 81 82 45 83 } 84
Note:
See TracChangeset
for help on using the changeset viewer.