source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 3.1 KB
Line 
1/*
2 * Copyright 2001-2002,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 */
17package org.apache.tools.ant.taskdefs.optional.junit;
18
19import java.io.OutputStream;
20import org.apache.xalan.xslt.XSLTInputSource;
21import org.apache.xalan.xslt.XSLTProcessor;
22import org.apache.xalan.xslt.XSLTProcessorFactory;
23import org.apache.xalan.xslt.XSLTResultTarget;
24import org.apache.tools.ant.BuildException;
25import org.xml.sax.SAXException;
26
27/**
28 * Xalan 1 executor. It will need a lot of things in the classpath:
29 * xerces for the serialization, xalan and bsf for the extension.
30 * @todo do everything via reflection to avoid compile problems ?
31 *
32 * @ant.task ignore="true"
33 */
34public class Xalan1Executor extends XalanExecutor {
35
36 private static final String xsltP = "org.apache.xalan.xslt.XSLTProcessor";
37
38 XSLTProcessor processor = null;
39 public Xalan1Executor() {
40 try {
41 processor = XSLTProcessorFactory.getProcessor();
42 } catch (SAXException e) {
43 e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
44 }
45 }
46 protected String getImplementation() {
47 return processor.getClass().getName();
48 }
49
50 protected String getProcVersion(String classNameImpl)
51 throws BuildException {
52 try {
53 // xalan 1
54 if (classNameImpl.equals(xsltP)){
55 return getXalanVersion(xsltP + "Version");
56 }
57 throw new BuildException("Could not find a valid processor version"
58 + " implementation from "
59 + classNameImpl);
60 } catch (ClassNotFoundException e){
61 throw new BuildException("Could not find processor version "
62 + "implementation", e);
63 }
64 }
65
66 void execute() throws Exception {
67 // need to quote otherwise it breaks because of "extra illegal tokens"
68 processor.setStylesheetParam("output.dir", "'"
69 + caller.toDir.getAbsolutePath() + "'");
70 XSLTInputSource xml_src = new XSLTInputSource(caller.document);
71 String system_id = caller.getStylesheetSystemId();
72 XSLTInputSource xsl_src = new XSLTInputSource(system_id);
73 OutputStream os = getOutputStream();
74 try {
75 XSLTResultTarget target = new XSLTResultTarget(os);
76 processor.process(xml_src, xsl_src, target);
77 } finally {
78 os.close();
79 }
80 }
81}
Note: See TracBrowser for help on using the repository browser.