// Path: src/java/se/idega/ehealth/npo/constants/LogDomains.java
// public class LogDomains
// {
// 	public static final String LOG_DOMAIN_WS="se.idega.ws";
// 	public static final String LOG_DOMAIN_GUI="se.idega.gui";
// 	public static final String LOG_DOMAIN_SECURITY="se.idega.security";
// }
// 
// Path: src/java/se/idega/ehealth/npo/exceptions/InfrastructureException.java
// public class InfrastructureException extends RuntimeException
// {
// 	public InfrastructureException(String message, Throwable cause)
// 	{
// 		super(message,cause);
// 	}
// 	
// 	public InfrastructureException(String message)
// 	{
// 		super(message);
// 	}
// 	
// 	public InfrastructureException(Throwable cause)
// 	{
// 		super(cause);
// 	}	
// }
// 
// Path: src/java/se/idega/ehealth/npo/libraries/CommonLib.java
// public class CommonLib
// {
// 	private static Log log = LogFactory.getLog(LogDomains.LOG_DOMAIN_GUI);
// 	
// 	public static Properties loadNpoProperties(ClassLoader cl)
// 	{ 
// 		try
// 		{
// 			InputStream is = cl.getResourceAsStream(Constants.NPO_PROPERTIES_FILENAME);			
// 			if (is==null)
// 			{
// 				log.error(Constants.NPO_PROPERTIES_FILENAME+" not found in classpath");
// 				throw new InfrastructureException(Constants.NPO_PROPERTIES_FILENAME+" not found in classpath");
// 			} 
// 			Properties props = new Properties();
// 			props.load(is);
// 			is.close();
// 			return props;
// 		} catch (Exception ex)
// 		{
// 			log.error("Exception",ex);
// 			throw new InfrastructureException(ex);
// 		}		
// 	}
// }


import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import org.jdom.xpath.XPath;
import se.idega.ehealth.npo.constants.LogDomains;
import se.idega.ehealth.npo.exceptions.InfrastructureException;
import se.idega.ehealth.npo.libraries.CommonLib;
	 */
	public String basicXSLTTransform(String xml,Source xslt,XsltParameterList xslParams ){
		String xslString;
		ByteArrayOutputStream bArrOutStream;
		bArrOutStream = new ByteArrayOutputStream();
		Source xmlSource = new StreamSource(new StringReader(xml));
		TransformerFactory transFact = TransformerFactory.newInstance();
		Templates cachedXSLT = null;
		Transformer trans = null;
		try{
		 cachedXSLT = transFact.newTemplates(xslt);
		}
		catch(TransformerConfigurationException tce){
            log.error("Exception",tce);
            throw new InfrastructureException(tce);	
		}
		try{
		trans = cachedXSLT.newTransformer();
		}
		catch(TransformerConfigurationException tce){
            log.error("Exception",tce);
            throw new InfrastructureException(tce);
		}
		//Get xsltParameters from XsltList ,if any, and sets them 
		if (xslParams != null){
			for(int i = 0;i< xslParams.size();i++){
				trans.setParameter(xslParams.getParam(i).getName(),xslParams.getParam(i).getValue());
			}
		}
		
// Path: src/java/se/idega/ehealth/npo/constants/LogDomains.java
// public class LogDomains
// {
// 	public static final String LOG_DOMAIN_WS="se.idega.ws";
// 	public static final String LOG_DOMAIN_GUI="se.idega.gui";
// 	public static final String LOG_DOMAIN_SECURITY="se.idega.security";
// }
// 
// Path: src/java/se/idega/ehealth/npo/exceptions/InfrastructureException.java
// public class InfrastructureException extends RuntimeException
// {
// 	public InfrastructureException(String message, Throwable cause)
// 	{
// 		super(message,cause);
// 	}
// 	
// 	public InfrastructureException(String message)
// 	{
// 		super(message);
// 	}
// 	
// 	public InfrastructureException(Throwable cause)
// 	{
// 		super(cause);
// 	}	
// }
// 
// Path: src/java/se/idega/ehealth/npo/libraries/CommonLib.java
// public class CommonLib
// {
// 	private static Log log = LogFactory.getLog(LogDomains.LOG_DOMAIN_GUI);
// 	
// 	public static Properties loadNpoProperties(ClassLoader cl)
// 	{ 
// 		try
// 		{
// 			InputStream is = cl.getResourceAsStream(Constants.NPO_PROPERTIES_FILENAME);			
// 			if (is==null)
// 			{
// 				log.error(Constants.NPO_PROPERTIES_FILENAME+" not found in classpath");
// 				throw new InfrastructureException(Constants.NPO_PROPERTIES_FILENAME+" not found in classpath");
// 			} 
// 			Properties props = new Properties();
// 			props.load(is);
// 			is.close();
// 			return props;
// 		} catch (Exception ex)
// 		{
// 			log.error("Exception",ex);
// 			throw new InfrastructureException(ex);
// 		}		
// 	}
// }


// Path: src/java/se/idega/ehealth/npo/XsltTransformBean.java
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import org.jdom.xpath.XPath;
import se.idega.ehealth.npo.constants.LogDomains;
import se.idega.ehealth.npo.exceptions.InfrastructureException;
import se.idega.ehealth.npo.libraries.CommonLib;

	 */
	public String basicXSLTTransform(String xml,Source xslt,XsltParameterList xslParams ){
		String xslString;
		ByteArrayOutputStream bArrOutStream;
		bArrOutStream = new ByteArrayOutputStream();
		Source xmlSource = new StreamSource(new StringReader(xml));
		TransformerFactory transFact = TransformerFactory.newInstance();
		Templates cachedXSLT = null;
		Transformer trans = null;
		try{
		 cachedXSLT = transFact.newTemplates(xslt);
		}
		catch(TransformerConfigurationException tce){
            log.error("Exception",tce);
            throw new InfrastructureException(tce);	
		}
		try{
		trans = cachedXSLT.newTransformer();
		}
		catch(TransformerConfigurationException tce){
            log.error("Exception",tce);
            throw new InfrastructureException(tce);
		}
		//Get xsltParameters from XsltList ,if any, and sets them 
		if (xslParams != null){
			for(int i = 0;i< xslParams.size();i++){
				trans.setParameter(xslParams.getParam(i).getName(),xslParams.getParam(i).getValue());
			}
		}
		
		try{