Changeset 3870
- Timestamp:
- 2003-03-12T16:55:47+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r3869 r3870 153 153 } 154 154 155 156 // takes a node with a resource elements inside it and extracts all the157 // HASH oids - name att for resource158 // generalise this for any element type? pass in the list, the element name, the att to extract159 // public static String [] getDocumentNameList(Element content) {160 161 // Node n = content.getFirstChild();162 // while (n!=null && !n.getNodeName().equals(DOCUMENT_ELEM+LIST_MODIFIER)) {163 // n = n.getNextSibling();164 // }165 // if (n==null) { // no docs found166 // return null;167 // }168 169 // NodeList docs = n.getChildNodes();170 171 // int numdocs = docs.getLength();172 // String []ids = new String[numdocs];173 // for (int i=0; i<numdocs; i++) {174 // Element e = (Element)docs.item(i);175 // String id = e.getAttribute(NAME_ATT);176 // // check that its a valid id - ie starts with HASH177 // // need to change this if use different ids178 179 // ids[i] = id;180 181 // }182 183 // return ids;184 // }185 186 // same as above function187 /** extracts metadata names out of an element */188 // public static String [] getMetaNameList(Element content) {189 // Node n = content.getFirstChild();190 // while (n!=null &&191 // !n.getNodeName().equals(METADATA_ELEM+LIST_MODIFIER)) {192 // n = n.getNextSibling();193 // }194 // if (n==null) { // no metadatas found195 // return null;196 // }197 // NodeList elems = n.getChildNodes();198 199 // int numelems = elems.getLength();200 // String []ids = new String[numelems];201 // for (int i=0; i<numelems; i++) {202 // Element e = (Element)elems.item(i);203 // String id = e.getAttribute(NAME_ATT);204 // ids[i] = id;205 // }206 207 // return ids;208 // }209 210 211 155 /** takes a paramList element, and gets a HashMap of name-value pairs 212 156 * if deep=true, extracts embedded params, otherwise just top level … … 235 179 return param_map; 236 180 } 237 /** takes a paramList element, and gets a HashMap of name-value pairs */238 // public static HashMap extractAllParams(Element xml) {239 240 // if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) {241 // System.err.println("GSXML:paramList element should have been passed to extractParams, instead it was "+xml.getNodeName());242 // return null;243 // }244 // NodeList params = xml.getElementsByTagName(PARAM_ELEM);245 // HashMap param_map = new HashMap();246 // for (int i=0; i<params.getLength(); i++) {247 // Element param = (Element)params.item(i);248 // String name=param.getAttribute(NAME_ATT);249 // String value=param.getAttribute(VALUE_ATT);250 // if (value.equals("")) { // the value is in the content of the param251 // value=getNodeText(param);252 // }253 // param_map.put(name, value);254 255 // }256 // return param_map;257 // }258 181 259 182 /** gets the value att or the text content */ … … 281 204 } 282 205 283 /** creates a new document Element */284 // public static Element createDocumentElement(Document owner, String oid) {285 // Element e = owner.createElement(DOCUMENT_ELEM);286 // e.setAttribute(NAME_ATT, oid);287 288 // return e;289 // }290 206 291 207 /** add text to a document/subsection element */ … … 315 231 } 316 232 317 /** adds an empty MetadataList elem to a doc, and returns a ref to it*/318 // public static Element addMetaList(Document owner, Element doc) {319 // Element list = owner.createElement(METADATA_ELEM+LIST_MODIFIER);320 // doc.appendChild(list);321 // return list;322 // }323 233 /** adds a metadata elem to a list */ 324 325 234 public static boolean addMetadata(Document owner, Element list, 326 235 String meta_name, String meta_value) { … … 457 366 return param; 458 367 } 459 /* 460 public static Element createClassifierDisplay(Document owner, String name, 461 String name_text) { 462 Element classifier = owner.createElement(CLASSIFIER_ELEM); 463 classifier.setAttribute(NAME_ATT, name); 464 classifier.appendChild(createTextElement(owner, DISPLAY_NAME_ELEM, name_text)); 465 466 return classifier; 467 } 468 469 * 368 470 369 /** returns the element parent/node_name[@attribute_name='attribute_value'] 471 370 */
Note:
See TracChangeset
for help on using the changeset viewer.