KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > xslt > XSLTProcessor


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.xslt;
17
18 import org.apache.avalon.framework.component.Component;
19 import org.apache.avalon.framework.parameters.Parameters;
20 import org.apache.cocoon.ProcessingException;
21 import org.apache.cocoon.environment.Source;
22 import org.apache.cocoon.environment.SourceResolver;
23 import org.xml.sax.XMLFilter JavaDoc;
24
25 import javax.xml.transform.Result JavaDoc;
26 import javax.xml.transform.sax.TransformerHandler JavaDoc;
27
28 /**
29  * This is the interface of the XSLT processor in Cocoon.
30  *
31  * @author <a HREF="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
32  * @version CVS $Id: XSLTProcessor.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  * @version 1.0
34  * @since July 11, 2001
35  */

36 public interface XSLTProcessor extends Component
37 {
38   /**
39    * The role implemented by an <code>XSLTProcessor</code>.
40    */

41   String JavaDoc ROLE = XSLTProcessor.class.getName();
42
43   /**
44    * The default factory identifier. (simply used as a pointer, the actual
45    * content is not meaningful)
46    */

47   String JavaDoc DEFAULT_FACTORY = "default";
48
49   /**
50    * Set the {@link org.apache.cocoon.environment.SourceResolver} for
51    * this instance. The <code>resolver</code> is invoked to return a
52    * <code>Source</code> object, given an HREF.
53    *
54    * @deprecated The processor can now simply lookup the source resolver.
55    * @param resolver a <code>SourceResolver</code> value
56    */

57   void setSourceResolver(SourceResolver resolver);
58
59   /**
60    * Set the TransformerFactory for this instance.
61    * The <code>factory</code> is invoked to return a
62    * <code>TransformerHandler</code> to perform the transformation.
63    *
64    * @param classname the name of the class implementing
65    * <code>TransformerFactory</code> value. If an error is found
66    * or the indicated class doesn't implement the required interface
67    * the original factory of the component is maintained.
68    */

69   void setTransformerFactory(String JavaDoc classname);
70
71   /**
72    * <p>Return a <code>TransformerHandler</code> for a given
73    * stylesheet <code>Source</code>. This can be used in a pipeline to
74    * handle the transformation of a stream of SAX events. See {@link
75    * org.apache.cocoon.transformation.TraxTransformer#setConsumer(org.apache.cocoon.xml.XMLConsumer)}
76    * for an example of how to use this method.
77    *
78    * <p>The additional <code>filter</code> argument, if it's not
79    * <code>null</code>, is inserted in the chain SAX events as an XML
80    * filter during the parsing or the source document.
81    *
82    * <p>This method caches the Source object and performs a reparsing
83    * only if this changes.
84    *
85    * @param stylesheet a <code>Source</code> value
86    * @param filter a <code>XMLFilter</code> value
87    * @return a <code>TransformerHandler</code> value
88    * @exception ProcessingException if an error occurs
89    */

90   TransformerHandler JavaDoc getTransformerHandler(Source stylesheet,
91                                            XMLFilter JavaDoc filter)
92     throws ProcessingException;
93
94   /**
95    * Same as {@link #getTransformerHandler(Source,XMLFilter)}, with
96    * <code>filter</code> set to <code>null</code> and <code>factory</code>
97    * set to <code>null</code>.
98    *
99    * @param stylesheet a <code>Source</code> value
100    * @return a <code>TransformerHandler</code> value
101    * @exception ProcessingException if an error occurs
102    * @see org.apache.cocoon.transformation.TraxTransformer#setConsumer(org.apache.cocoon.xml.XMLConsumer)
103    */

104   TransformerHandler JavaDoc getTransformerHandler(Source stylesheet)
105     throws ProcessingException;
106
107   /**
108    * Applies an XSLT stylesheet to an XML document. The source and
109    * stylesheet documents are specified as <code>Source</code>
110    * objects. The result of the transformation is placed in
111    * <code>result</code>, which should be properly initialized before
112    * invoking this method. Any additional parameters passed in
113    * <code>params</code> will become arguments to the stylesheet.
114    *
115    * @param source a <code>Source</code> value
116    * @param stylesheet a <code>Source</code> value
117    * @param params a <code>Parameters</code> value
118    * @param result a <code>Result</code> value
119    * @exception ProcessingException if an error occurs
120    */

121   void transform(Source source, Source stylesheet, Parameters params,
122                  Result JavaDoc result)
123     throws ProcessingException;
124 }
125
Popular Tags