01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19:
20: package de.schlund.pfixxml.targets;
21:
22: import java.util.TreeMap;
23:
24: import javax.xml.transform.TransformerException;
25:
26: import org.w3c.dom.Document;
27:
28: import de.schlund.pfixxml.resources.FileResource;
29: import de.schlund.pfixxml.resources.ResourceUtil;
30: import de.schlund.pfixxml.util.Xml;
31: import de.schlund.pfixxml.util.Xslt;
32:
33: /**
34: * XSLVirtualTarget.java
35: *
36: * Created: Mon Jul 23 21:53:06 2001
37: *
38: * @author <a href="mailto:jtl@schlund.de">Jens Lautenbacher</a>
39: *
40: */
41:
42: public class XSLVirtualTarget extends VirtualTarget {
43:
44: public XSLVirtualTarget(TargetType type, TargetGenerator gen,
45: String key, Themes themes) throws Exception {
46: this .type = type;
47: this .generator = gen;
48: this .targetkey = key;
49: this .themes = themes;
50: this .params = new TreeMap<String, Object>();
51: this .auxdepmanager = new AuxDependencyManager(this );
52: auxdepmanager.tryInitAuxdepend();
53: }
54:
55: /**
56: * @see de.schlund.pfixxml.targets.TargetImpl#getValueFromDiscCache()
57: */
58: protected Object getValueFromDiscCache()
59: throws TransformerException {
60: FileResource thefile = ResourceUtil.getFileResource(
61: getTargetGenerator().getDisccachedir(), getTargetKey());
62: if (thefile.exists() && thefile.isFile()) {
63: return Xslt.loadTemplates(generator.getXsltVersion(),
64: thefile, this );
65: } else {
66: return null;
67: }
68: }
69:
70: public Document getDOM() throws TargetGenerationException {
71: // Make sure we have an up-to-date version
72: this .getValue();
73:
74: FileResource thefile = ResourceUtil.getFileResource(
75: getTargetGenerator().getDisccachedir(), getTargetKey());
76: if (thefile.exists() && thefile.isFile()) {
77: try {
78: return Xml.parse(generator.getXsltVersion(), thefile);
79: } catch (TransformerException e) {
80: throw new TargetGenerationException(
81: "Error while reading DOM from disccache for target "
82: + getTargetKey(), e);
83: }
84: } else {
85: return null;
86: }
87: }
88:
89: } // XSLVirtualTarget
|