View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.rice.ken.util;
17  
18  import java.io.ByteArrayInputStream;
19  import java.io.File;
20  
21  import javax.xml.transform.stream.StreamSource;
22  
23  import org.apache.log4j.Logger;
24  
25  /**
26   * This class is responsible for resolving Xsl from files and Strings.
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class XslSourceResolver {
30      protected final Logger LOG = Logger.getLogger(getClass());
31  
32      /**
33       * Constructs a XslSourceResolver.java.
34       */
35      public XslSourceResolver() {
36  	super();
37  	// TODO Auto-generated constructor stub
38      }
39      
40      /**
41       * 
42       * This method resolves xsl from a file
43       * @param path location of xsl file
44       * @return a StreamSource
45       */
46      public StreamSource resolveXslFromFile(String path) {
47  	StreamSource xslsource = new StreamSource(new File(path));
48  	return xslsource;
49      }
50      
51      /**
52       * 
53       * This method resolves xsl from a string
54       * @param path location of xsl file
55       * @return a StreamSource
56       */
57      public StreamSource resolveXslFromString(String s) {
58  	ByteArrayInputStream bytestream = new ByteArrayInputStream(s.getBytes());
59  	StreamSource xslsource = new StreamSource(bytestream);
60  	return xslsource;
61      }
62  }