001/**
002 * Copyright 2005-2015 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.ken.util;
017
018import java.io.ByteArrayInputStream;
019import java.io.File;
020
021import javax.xml.transform.stream.StreamSource;
022
023import org.apache.log4j.Logger;
024
025/**
026 * This class is responsible for resolving Xsl from files and Strings.
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029public class XslSourceResolver {
030    protected final Logger LOG = Logger.getLogger(getClass());
031
032    /**
033     * Constructs a XslSourceResolver.java.
034     */
035    public XslSourceResolver() {
036        super();
037        // TODO Auto-generated constructor stub
038    }
039    
040    /**
041     * 
042     * This method resolves xsl from a file
043     * @param path location of xsl file
044     * @return a StreamSource
045     */
046    public StreamSource resolveXslFromFile(String path) {
047        StreamSource xslsource = new StreamSource(new File(path));
048        return xslsource;
049    }
050    
051    /**
052     * 
053     * This method resolves xsl from a string
054     * @param path location of xsl file
055     * @return a StreamSource
056     */
057    public StreamSource resolveXslFromString(String s) {
058        ByteArrayInputStream bytestream = new ByteArrayInputStream(s.getBytes());
059        StreamSource xslsource = new StreamSource(bytestream);
060        return xslsource;
061    }
062}