Changeset 27090
- Timestamp:
- 2013-03-15T14:09:47+13:00 (10 years ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
r26848 r27090 901 901 } 902 902 903 // We now no longer create a document with doctype before the transformation 904 // We let the XMLTransformer do the work of first working out the doctype from any 905 // that may be set in the (merged) stylesheets and then setting the doctype when transforming 906 907 /* 903 908 // Try to get the system and public ID from the current skin xsl document 904 909 // otherwise keep the default values. … … 929 934 930 935 docWithDoctype = converter.newDOM(qualifiedName, publicID, systemID); 936 */ 931 937 932 938 //System.out.println("Generate final HTML from current skin") ; … … 975 981 } 976 982 977 Node finalResult = this.transformer.transform(skinAndLibraryDoc, doc, config_params, docWithDoctype); 983 984 // The transformer will now work out the resulting doctype from any set in the (merged) stylesheets and 985 // will set this in the output document it creates. So don't pass in any docWithDocType to the transformer 986 //Node finalResult = this.transformer.transform(skinAndLibraryDoc, doc, config_params, docWithDoctype); 987 Node finalResult = this.transformer.transform(skinAndLibraryDoc, doc, config_params); 978 988 979 989 if (_debug) -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java
r26513 r27090 36 36 import java.util.Iterator; 37 37 import java.util.Map; 38 import java.util.Properties; 38 39 import java.util.Set; 39 40 40 41 import javax.xml.parsers.DocumentBuilderFactory; 41 42 import javax.xml.transform.ErrorListener; 43 import javax.xml.transform.OutputKeys; 42 44 import javax.xml.transform.Source; 43 45 import javax.xml.transform.Transformer; … … 225 227 } 226 228 229 // This method will now set the docType in the new document created and returned, if any are specified in the 230 // (merged) stylesheet being applied. The docDocType parameter is therefore no longer necessary nor used by default. 227 231 protected Node transform(Document stylesheet, Document source, HashMap<String, Comparable> parameters, Document docDocType, Document resultNode) 228 232 { … … 249 253 // the transformation has a DocType. For that to happen, we need to create 250 254 // the DOMResult using a Document with a predefined docType. 251 // If we don't have a DocType then do the transformation with a DOMResult 252 // that does not contain any doctype (like we use to do before). 253 DOMResult result = docDocType == null ? new DOMResult() : new DOMResult(docDocType); 255 256 // When the DOCType is not explicitly specified (default case), the docDocType variable is null 257 // In such a case, the transformer will work out the docType and output method and the rest 258 // from the stylesheet. Better to let the transformer work this out than GS manually aggregating 259 // all xsls being applied and the GS code deciding on which output method and doctype to use. 260 261 //DOMResult result = docDocType == null ? new DOMResult() : new DOMResult(docDocType); 262 DOMResult result = null; 263 264 Properties props = transformer.getOutputProperties(); 265 if(docDocType == null) { // default case 266 267 String outputMethod = props.getProperty(OutputKeys.METHOD); 268 if(outputMethod.equals("html")) { 269 String doctype_public = props.getProperty(OutputKeys.DOCTYPE_PUBLIC); 270 String doctype_system = props.getProperty(OutputKeys.DOCTYPE_SYSTEM); 271 272 if(doctype_public == null) { 273 doctype_public = ""; // or default to PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"? 274 } 275 if(doctype_system == null) { 276 doctype_system = ""; // or default to "http://www.w3.org/TR/html4/loose.dtd"? 277 } 278 279 Document docDocTypeFromTransformer = XMLConverter.newDOM(outputMethod, doctype_public, doctype_system); 280 result = new DOMResult(docDocTypeFromTransformer); 281 } 282 // if output method=xml, the <?xml ?> processing method goes missing hereafter, although it 283 // still exists in OutputKeys' VERSION, ENCODING and OMIT_XML_DECLARATION props at this point 284 285 } else { // if document with doctype was already specified (no longer the default case) 286 result = new DOMResult(docDocType); 287 } 288 // At this point if we haven't initialised result yet, set it to an empty DOMResult 289 if(result == null) { 290 result = new DOMResult(); 291 } 292 293 254 294 if (resultNode != null) 255 295 {
Note:
See TracChangeset
for help on using the changeset viewer.