1 package net.sf.tomp.xtcl.command;
2
3 import javax.xml.transform.Templates;
4 import javax.xml.transform.TransformerConfigurationException;
5 import javax.xml.transform.TransformerFactory;
6 import javax.xml.transform.stream.StreamSource;
7
8 import net.sf.tomp.xtcl.Context;
9 import net.sf.tomp.xtcl.filter.XTFilterFactory;
10
11 import org.xml.sax.XMLFilter;
12
13 /***
14 * Filter based on XSLT transformation.
15 *
16 * @author tomp
17 */
18 public class XSLTFilterCommand extends StyleFilterCommand {
19
20 /***
21 * Gets the necesssary factories and creates the transformation
22 * filter based on the XSLT style.
23 *
24 * @see net.sf.tomp.xtcl.command.StyleFilterCommand#makeFilter(net.sf.tomp.xtcl.Context, java.lang.String)
25 */
26 protected XMLFilter makeFilter(Context context, String styleRef)
27 throws TransformerConfigurationException {
28
29 TransformerFactory tf = context.getTransformerFactory();
30 XTFilterFactory factory = context.getXTFilterFactory();
31
32 Templates templates = styleRef.startsWith("$") ? context
33 .refToStyle(styleRef) : tf.newTemplates(new StreamSource(
34 context.getFile(styleRef)));
35
36 return factory.newTransformerFilter(templates);
37 }
38
39 /***
40 *
41 * @return "XSLT FILTER " + super.toString();
42 */
43 public String toString() {
44 return "XSLT FILTER " + super.toString();
45 }
46 }
47
48
49
50
51
52
53
54
55
56
57