Changeset 25914
- Timestamp:
- 2012-07-10T10:25:12+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXSLT.java
r25913 r25914 19 19 package org.greenstone.gsdl3.util; 20 20 21 import java.io.BufferedWriter;22 21 import java.io.File; 23 import java.io.FileWriter;24 22 import java.util.ArrayList; 25 23 import java.util.Vector; … … 28 26 import org.w3c.dom.Document; 29 27 import org.w3c.dom.Element; 30 import org.w3c.dom.NamedNodeMap;31 28 import org.w3c.dom.Node; 32 29 import org.w3c.dom.NodeList; … … 84 81 //main.insertBefore(main_xsl.importNode(node, true), main.getFirstChild()); 85 82 main.insertBefore(main_xsl.importNode(node, true), insertion_point); 86 87 83 } 88 84 } … … 111 107 } // for each include 112 108 113 // do we have a new insertion point?? 114 Element last_output = GSXML.getLastElementByTagNameNS(main, "http://www.w3.org/1999/XSL/Transform", "output"); 115 if (last_output != null) 116 { 117 insertion_point = last_output.getNextSibling(); 118 } 119 120 // outputs 121 children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "output"); 122 for (int i = 0; i < children.getLength(); i++) 123 { 124 Element node = (Element) children.item(i); 125 // If the new xsl:output element is identical (in terms of the value for the method attr) 126 // to any in the merged document, don't copy it over 127 if (GSXML.getNamedElementNS(main, "http://www.w3.org/1999/XSL/Transform", "output", "method", node.getAttribute("method")) == null) 128 { 109 if (main.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "output").getLength() == 0) 110 { 111 // outputs 112 children = extra_xsl.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "output"); 113 for (int i = 0; i < children.getLength(); i++) 114 { 115 Element node = (Element) children.item(i); 116 // If the new xsl:output element is identical (in terms of the value for the method attr) 117 // to any in the merged document, don't copy it over 118 129 119 main.insertBefore(main_xsl.importNode(node, true), insertion_point); 130 120 } … … 140 130 // to any in the merged document, don't copy it over 141 131 if (GSXML.getNamedElementNS(main, "http://www.w3.org/1999/XSL/Transform", "variable", "name", node.getAttribute("name")) == null) 132 { 133 main.appendChild(main_xsl.importNode(node, true)); 134 } 135 } 136 137 // params - only top level ones!! 138 // append to end of document 139 children = GSXML.getChildrenByTagNameNS(extra_xsl, "http://www.w3.org/1999/XSL/Transform", "param"); 140 for (int i = 0; i < children.getLength(); i++) 141 { 142 Element node = (Element) children.item(i); 143 // If the new xsl:import element is identical (in terms of href attr value) 144 // to any in the merged document, don't copy it over 145 if (GSXML.getNamedElementNS(main, "http://www.w3.org/1999/XSL/Transform", "param", "name", node.getAttribute("name")) == null) 142 146 { 143 147 main.appendChild(main_xsl.importNode(node, true)); … … 180 184 main.appendChild(main_xsl.importNode(node, true)); 181 185 } 186 187 if (GSXML.getNamedElementNS(main, "http://www.w3.org/1999/XSL/Transform", "template", "name", template_name) == null) 188 { 189 main.appendChild(main_xsl.importNode(node, true)); 190 } 182 191 } 183 192 } … … 217 226 } 218 227 219 public static void inlineImportAndIncludeFiles(Document doc, String pathExtra , int depth)220 { 221 inlineImportAndIncludeFilesDebug(doc, pathExtra, depth,false, null);222 } 223 224 public static void inlineImportAndIncludeFilesDebug(Document doc, String pathExtra, int depth,boolean debug, String docFileName)228 public static void inlineImportAndIncludeFiles(Document doc, String pathExtra) 229 { 230 inlineImportAndIncludeFilesDebug(doc, pathExtra, false, null); 231 } 232 233 public static void inlineImportAndIncludeFilesDebug(Document doc, String pathExtra, boolean debug, String docFileName) 225 234 { 226 235 XMLConverter converter = new XMLConverter(); 227 236 228 String path = pathExtra; 229 if (path == null) 230 { 231 path = ""; 232 } 237 String path = (pathExtra == null) ? "" : pathExtra; 233 238 234 239 NodeList importList = doc.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "import"); 235 240 NodeList includeList = doc.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform", "include"); 236 241 237 if (importList.getLength() == 0)238 {239 importList = doc.getElementsByTagName("xsl:import");240 }241 if (includeList.getLength() == 0)242 {243 includeList = doc.getElementsByTagName("xsl:include");244 }245 246 242 for (int i = 0; i < importList.getLength() + includeList.getLength(); i++) 247 243 { 248 244 Element current = (Element) ((i < importList.getLength()) ? importList.item(i) : includeList.item(i - importList.getLength())); 249 245 String href = current.getAttribute("href"); 250 251 S tring filePath = GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), "oran") + File.separator + "transform" + File.separator + path.replace("/", File.separator) + href.replace("/", File.separator);246 String filePath = GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), "default") + File.separator + "transform" + File.separator + path.replace("/", File.separator) + href.replace("/", File.separator); 247 System.err.println("ADDING IN " + filePath); 252 248 253 249 try 254 250 { 255 Document inlineDoc = converter.getDOM(new File(filePath) );251 Document inlineDoc = converter.getDOM(new File(filePath), "UTF-8"); 256 252 257 253 String newPath = path; … … 263 259 264 260 //Do this recursively 265 inlineImportAndIncludeFilesDebug(inlineDoc, newPath, depth + 1, debug, filePath); 261 inlineImportAndIncludeFilesDebug(inlineDoc, newPath, debug, filePath); 262 266 263 GSXSLT.mergeStylesheetsDebug(doc, inlineDoc.getDocumentElement(), false, debug, docFileName, filePath); 267 264 }
Note:
See TracChangeset
for help on using the changeset viewer.