Commit 3aeaa627 authored by Fabien Triolet's avatar Fabien Triolet
Browse files

If fileName ( XSL stylesheet) is null then the identity trasnformation is apply.

parent 49b31d2e
/**
* $Id: TTransformation.java,v 1.6 2003-01-07 08:13:59 triolet Exp $
* $Id: TTransformation.java,v 1.7 2003-04-02 15:03:37 triolet Exp $
*
* Transmorpher
*
......@@ -150,33 +150,40 @@ public abstract class TTransformation extends TProcessBasic {
try {
long xslLastModified=0 ;
String systemID="";
if(fileName.startsWith("http://")){
URL url = new URL(fileName);
URLConnection urlConnect = url.openConnection();
xslLastModified=urlConnect.getLastModified();
systemID=url.toExternalForm();
}
else{
File xsltFile = new File(fileName);
xslLastModified = xsltFile.lastModified();
systemID=xsltFile.toURL().toExternalForm();
}
MapEntry entry = (MapEntry)cache.get(fileName);
if (entry != null) {
if (xslLastModified > entry.lastModified) {
entry = null;
if(fileName!=null){
if(fileName.startsWith("http://")){
URL url = new URL(fileName);
URLConnection urlConnect = url.openConnection();
xslLastModified=urlConnect.getLastModified();
systemID=url.toExternalForm();
}
else{
File xsltFile = new File(fileName);
xslLastModified = xsltFile.lastModified();
systemID=xsltFile.toURL().toExternalForm();
}
MapEntry entry = (MapEntry)cache.get(fileName);
if (entry != null) {
if (xslLastModified > entry.lastModified) {
entry = null;
}
}
if (entry == null) {
InputSource SS = new InputSource(systemID);
// Create a TransformerHandler for each stylesheet.
templates = getTransformerFactory().newTemplates(new SAXSource(SS));
entry = new MapEntry(xslLastModified, templates);
cache.put(fileName, entry);
}
templates = entry.templates;
iTransformerHandler = getTransformerFactory().newTransformerHandler(templates);
setOutputProperties();
}
if (entry == null) {
InputSource SS = new InputSource(systemID);
// Create a TransformerHandler for each stylesheet.
templates = getTransformerFactory().newTemplates(new SAXSource(SS));
entry = new MapEntry(xslLastModified, templates);
cache.put(fileName, entry);
else{
// identity
iTransformerHandler = getTransformerFactory().newTransformerHandler();
setOutputProperties();
}
templates = entry.templates;
iTransformerHandler = getTransformerFactory().newTransformerHandler(templates);
setOutputProperties();
} catch (Exception e) {
throw new TMRuntimeException(e, "TTransformation initialization failled");
}
......@@ -223,7 +230,11 @@ public abstract class TTransformation extends TProcessBasic {
public void reset() {
try {
iTransformerHandler = null;
iTransformerHandler = getTransformerFactory().newTransformerHandler(templates);
if (templates!=null)
iTransformerHandler = getTransformerFactory().newTransformerHandler(templates);
else
//identity
iTransformerHandler = getTransformerFactory().newTransformerHandler();
setOutputProperties();
} catch (Exception e) {
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment