KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > xsl > XalanXSLProcessor


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.taglibs.xsl;
17
18 /**
19  * Xalan XSL Processor.
20  *
21  * Author Mandar Raje [mandar@eng.sun.com].
22  */

23
24 import java.io.Writer JavaDoc;
25 import javax.servlet.jsp.JspException JavaDoc;
26 import org.xml.sax.SAXException JavaDoc;
27 import org.apache.xalan.xslt.XSLTProcessorFactory;
28 import org.apache.xalan.xslt.XSLTInputSource;
29 import org.apache.xalan.xslt.XSLTResultTarget;
30 import org.apache.xalan.xslt.XSLTProcessor;
31
32
33 public class XalanXSLProcessor implements XSLProcessor {
34
35     public void process(String JavaDoc url, String JavaDoc xsl, Writer JavaDoc out)
36     throws JspException JavaDoc {
37
38     try {
39         // Have the XSLTProcessorFactory obtain a interface to a
40
// new XSLTProcessor object.
41
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
42         
43         // Have the XSLTProcessor processor object transform "foo.xml" to
44
// System.out, using the XSLT instructions found in "foo.xsl".
45
processor.process(new XSLTInputSource(url),
46                   new XSLTInputSource(xsl),
47                   new XSLTResultTarget(out));
48     } catch(SAXException JavaDoc sexp) {
49         throw new JspException JavaDoc("SAXParser Exception: " + sexp.getMessage());
50     }
51     }
52 }
53
54
55
56
57
58
59
60
61
62
63
Popular Tags