| 1 10 package org.mmbase.module; 11 12 import java.util.*; 13 import java.io.*; 14 15 import org.mmbase.module.core.MMBaseContext; 16 import org.mmbase.util.*; 17 import org.mmbase.util.logging.Logger; 18 import org.mmbase.util.logging.Logging; 19 20 33 public class XSLConvert extends ProcessorModule { 34 35 private static final Logger log = Logging.getLoggerInstance(XSLConvert.class); 36 37 private String configpath; 38 39 public void init() { 40 configpath = MMBaseContext.getConfigPath(); 41 } 42 43 public XSLConvert() {} 44 45 50 public Vector getList(PageInfo sp,StringTagger tagger, String value) { 51 return null; 52 } 53 54 57 public boolean process(PageInfo sp, Hashtable cmds,Hashtable vars) { 58 return false; 59 } 60 61 70 public String replace(PageInfo sp, String cmds) { 71 StringTokenizer tok = new StringTokenizer(cmds,"-\n\r"); 72 int count = tok.countTokens(); 73 String [] argv = new String [count]; 74 for (int i=0; i<count; i++) { 75 argv[i] = tok.nextToken(); 76 } 77 78 if (argv.length != 2) { 79 return "$MOD-XSLCONVERT should have two arguments, e.g. $MOD-XSLCONVERT-xmlPath-xslFile"; 80 } else { 81 String xmlPath = configpath+File.separator+argv[0]; 82 String xslPath = configpath+File.separator+"xslt"+File.separator+argv[1]; 83 84 if (!xslPath.endsWith(".xsl")) { 85 xslPath = xslPath+".xsl"; 86 } 87 if (!xmlPath.endsWith(".xml")) { 88 xmlPath = xmlPath+".xml"; 89 } 90 91 return transform(xmlPath,xslPath); 92 } 93 } 95 96 103 public String transform(String xmlPath, String xslPath) { 104 if (log.isDebugEnabled()) { 106 log.debug("XML file = "+xmlPath); 107 log.debug("XSL file = "+xslPath); 108 } 109 return XSLTransformer.transform(xmlPath,xslPath); 110 } 111 112 public String getModuleInfo() { 113 return "Support XSL transformations of XML files, cjr@dds.nl"; 114 } 115 116 } 117 | Popular Tags |