View Javadoc

1   package net.sf.tomp.xtcl.command;
2   
3   import net.sf.tomp.xtcl.Context;
4   import net.sf.tomp.xtcl.filter.XTFilterFactory;
5   
6   import org.xml.sax.XMLFilter;
7   
8   import javax.xml.transform.Templates;
9   import javax.xml.transform.TransformerConfigurationException;
10  import javax.xml.transform.TransformerFactory;
11  import javax.xml.transform.stream.StreamSource;
12  
13  /***
14   * Filter based on STX transformation.
15   * 
16   * @author tomp
17   */
18  public class STXFilterCommand extends StyleFilterCommand {
19  
20  	/***
21  	 * Gets the necesssary factories and creates the transformation 
22  	 * filter based on the STX (Joost) 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.getJoostTransformerFactory();
30  		XTFilterFactory factory = context.getXTFilterFactory();
31  
32  		Templates templates = styleRef.startsWith("$") ? context
33  				.refToJoostStyle(styleRef) : tf.newTemplates(new StreamSource(
34  				context.getFile(styleRef)));
35  
36  		return factory.newJoostFilter(templates);
37  	}
38  
39  	/***
40  	 * @return "JOOST FILTER " + super.toString();
41  	 */
42  	public String toString() {
43  		return "JOOST FILTER " + super.toString();
44  	}
45  }
46  
47  /*
48   * The contents of this file are subject to the Mozilla Public License Version
49   * 1.1 (the "License"); you may not use this file except in compliance with the
50   * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
51   * Software distributed under the License is distributed on an "AS IS" basis,
52   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
53   * the specific language governing rights and limitations under the License. The
54   * Original Code is: all this file. The Initial Developer of the Original Code
55   * is: Tomas Pitner, Masaryk University in Brno, Czech Republic. Contributor(s):
56   */