org.semwebcentral.sweetrules.util
Class SweetXSLTHelper

java.lang.Object
  extended byorg.semwebcentral.sweetrules.util.SweetXSLTHelper

public class SweetXSLTHelper
extends java.lang.Object


Helper class to abstract XSLT operations Current implementation is not based on XSLTC

Modified on: Aug 25, 2004, 2:07:34 PM

Author:
Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Dr. Said Tabet, Chitravanu Neogy

Constructor Summary
SweetXSLTHelper()
           
 
Method Summary
static java.lang.String applyTransformation(java.lang.String xslFileURL, java.lang.String sourceData, java.util.Properties transformParams)
          Applies the XSLT transformations either using batch file or the XSLT API, which ever works
private static java.lang.String applyTransformationViaFiles(java.lang.String xslFileURL, java.lang.String sourceData, java.util.Properties transformParams)
          Applies the XSLT transformation via batch file/script files.
private static java.lang.String applyTransformationViaXSLTAPI(java.lang.String xslFileURL, java.lang.String sourceData, java.util.Properties transformParams)
          This applies the transformation specified in the xslFile on the sourceData and returns the results using the XSLT transformer API The parameters to the transform must be passed as Properties i.e (name, value) pair
private static java.lang.String[] generateCommandLineArgsForXSLTScript(java.lang.String xslFilePath, java.lang.String sourceFilePath, java.lang.String targetFilePath, java.util.Properties transformParams, java.lang.String classPath)
          Get the parameters for a command line oriented invocation
private static int invokeXSLTTransformScript(java.lang.String[] args)
          Invokes the XSLT transform script
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SweetXSLTHelper

public SweetXSLTHelper()
Method Detail

applyTransformation

public static java.lang.String applyTransformation(java.lang.String xslFileURL,
                                                   java.lang.String sourceData,
                                                   java.util.Properties transformParams)
                                            throws SweetException
Applies the XSLT transformations either using batch file or the XSLT API, which ever works

Parameters:
xslFileURL - The URL of XSLT source file
sourceData - The sourceData to be transformed
transformParams - The parameters to the transformation, if it is null it is ignored
Returns:
String The output of transformation
Throws:
SweetException - if an error occurs

applyTransformationViaXSLTAPI

private static java.lang.String applyTransformationViaXSLTAPI(java.lang.String xslFileURL,
                                                              java.lang.String sourceData,
                                                              java.util.Properties transformParams)
                                                       throws SweetException
This applies the transformation specified in the xslFile on the sourceData and returns the results using the XSLT transformer API The parameters to the transform must be passed as Properties i.e (name, value) pair

Parameters:
xslFileURL - The URL of XSLT source file
sourceData - The sourceData to be transformed
transformParams - The parameters to the transformation, if it is null it is ignored
Returns:
String The output of transformation
Throws:
SweetException - if an error occurs

applyTransformationViaFiles

private static java.lang.String applyTransformationViaFiles(java.lang.String xslFileURL,
                                                            java.lang.String sourceData,
                                                            java.util.Properties transformParams)
                                                     throws SweetException
Applies the XSLT transformation via batch file/script files. This is a hack to handle classpath problems

Parameters:
xslFileURL - The xsl file URL
sourceData - The source data
transformParams - The transformation parameters
Returns:
The Output of transformation
Throws:
SweetException - if an error occurs

invokeXSLTTransformScript

private static int invokeXSLTTransformScript(java.lang.String[] args)
                                      throws SweetException
Invokes the XSLT transform script

Parameters:
args - The arguments for the script
Returns:
Result of executing the script
Throws:
SweetException

generateCommandLineArgsForXSLTScript

private static java.lang.String[] generateCommandLineArgsForXSLTScript(java.lang.String xslFilePath,
                                                                       java.lang.String sourceFilePath,
                                                                       java.lang.String targetFilePath,
                                                                       java.util.Properties transformParams,
                                                                       java.lang.String classPath)
Get the parameters for a command line oriented invocation

Parameters:
xslFilePath - The xsl file path
sourceFilePath - The source file path
targetFilePath - The target file path
transformParams - The parameters for this transformation
classPath - The classpath for XSLT
Returns:
The parameters required to perform the translation