source: trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXSLT.java@ 3968

Last change on this file since 3968 was 3450, checked in by kjdon, 22 years ago

utility class for manipulating greenstones xslt files

  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1package org.greenstone.gsdl3.util;
2
3import org.w3c.dom.Node;
4import org.w3c.dom.Element;
5import org.w3c.dom.NodeList;
6import org.w3c.dom.Document;
7import org.w3c.dom.Text;
8
9import java.util.HashMap;
10
11/** various functions for manipulating Greenstone xslt */
12public class GSXSLT {
13
14 /** takes a stylesheet Document, and adds in any child nodes from extra_xsl
15 */
16 public static void mergeStylesheets(Document main_xsl, Element extra_xsl) {
17
18 Element main = main_xsl.getDocumentElement();
19
20 NodeList children = extra_xsl.getChildNodes();
21 for (int i=0; i<children.getLength(); i++) {
22 main.appendChild(main_xsl.importNode(children.item(i), true));
23 }
24
25 }
26
27 /** takes any import or include nodes, and creates absolute path names
28 * for the files
29 */
30 public static void absoluteIncludePaths(Document stylesheet,
31 ConfigVars config) {
32
33
34 Element base_node = stylesheet.getDocumentElement();
35 Node child = base_node.getFirstChild();
36 while(child != null) {
37 String name = child.getNodeName();
38 if (name.equals("xsl:import") || name.equals("xsl:include")) {
39 ((Element)child).setAttribute("href", GSFile.stylesheetFile(config, ((Element)child).getAttribute("href")));
40 }
41 child = child.getNextSibling();
42 }
43
44 }
45}
Note: See TracBrowser for help on using the repository browser.