|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.dlese.dpc.xml.XSLTransformer
Transforms files or Strings using XSL stylesheets. Note: some members of this class can be run as a stand-alone class that can be invoked from the command line or from a servlet environment.
Constructor Summary | |
---|---|
XSLTransformer()
Constructor does nothing. |
Method Summary | |
---|---|
static String |
encodeCharsInString(String stg)
Substitutes escape chars for certain sensitive characthers that don't play well in file names or file paths. |
static String |
encodeStringIntoHex(String stg)
Substitutes hex values for all characters EXCEPT digits, letters, and the chars shown below. |
static Transformer |
getTransformer(String xslFilePath)
Gets a Transformer used to transform XML using
a given XSL stylesheet. |
StringBuffer |
transform(String xslFilePath,
String inputFilesDir,
String outputFilesDir)
Perform the transform on each file in the inputFilesDir, using the given xsl stylesheet, placing the resulting transformed files into outpuFilesDir. |
StringBuffer |
transform(String xslFilePath,
String inputFilesDir,
String[] inputFileNames,
String outputFilesDir)
Perform the transform files in inputFilesDir corresponding to the inputFileNames passed in, using the given xsl stylesheet, placing the resulting transformed files into outpuFilesDir. |
static String |
transformFile(File inputFile,
Transformer transformer)
Transforms an XML file using a pre-compiled Transformer . |
static String |
transformFile(String inputFilePath,
String xslFilePath)
Transforms an XML file using an XSL stylesheet. |
static String |
transformFile(String inputFilePath,
Transformer transformer)
Transforms an XML file using a pre-compiled Transformer . |
static StringWriter |
transformFileToWriter(String inputFilePath,
String xslFilePath)
Transforms an XML file using an XSL stylesheet. |
static StringWriter |
transformFileToWriter(String inputFilePath,
Transformer transformer)
Transforms an XML file using a pre-compiled Transformer . |
static String |
transformString(String xmlString,
String xslFilePath)
Transforms an XML String using an XSL stylesheet. |
static String |
transformString(String xmlString,
Transformer transformer)
Transforms an XML String using a pre-compiled Transformer . |
static StringWriter |
transformStringToWriter(String xmlString,
String xslFilePath)
Transforms an XML String using an XSL stylesheet. |
static StringWriter |
transformStringToWriter(String xmlString,
Transformer transformer)
Transforms an XML String using a pre-compiled Transformer . |
static void |
transformToFile(File inputFile,
FileOutputStream fos,
Transformer transformer)
Transform a single file to the given FileOutputStream using the given transformer. |
static void |
transformToFile(File inputFile,
File outputFile,
Transformer transformer)
Transform a single file to the given output file using the given transformer. |
static void |
transformToFile(String inputFilePath,
String outputFilePath,
Transformer transformer)
Transform a single file to a file at the given output path using the given transformer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XSLTransformer()
Method Detail |
public StringBuffer transform(String xslFilePath, String inputFilesDir, String outputFilesDir) throws Exception
xslFilePath
- Path to an XSL stylesheet.inputFilesDir
- Path to a directory of XML files.outputFilesDir
- Path to a directory where transformed Files will be
saved.
Exception
- If error.public StringBuffer transform(String xslFilePath, String inputFilesDir, String[] inputFileNames, String outputFilesDir) throws Exception
xslFilePath
- Path to an XSL stylesheet.inputFilesDir
- Path to a directory of XML files.inputFileNames
- An array of file names.outputFilesDir
- Path to a directory where transformed Files will be
saved.
Exception
- If error.public static final void transformToFile(String inputFilePath, String outputFilePath, Transformer transformer) throws Exception
inputFilePath
- The input file to transform.outputFilePath
- The output file where transformed content will be
saved.transformer
- The Transformer used to perform the transform.
Exception
- If unable to perform the transform.public static final void transformToFile(File inputFile, File outputFile, Transformer transformer) throws Exception
inputFile
- The input file to transform.outputFile
- The output file where transformed content will be
saved.transformer
- The Transformer used to perform the transform.
Exception
- If unable to perform the transform.public static final void transformToFile(File inputFile, FileOutputStream fos, Transformer transformer) throws Exception
inputFile
- The input file to transform.fos
- The FileOutputStream where transformed content will
be saved.transformer
- The Transformer used to perform the transform.
Exception
- If unable to perform the transform.public static final String transformFile(String inputFilePath, Transformer transformer)
Transformer
. Use getTransformer(String
xslFilePath)
to produce a reusable Transformer
for a given XSL stylesheet.
inputFilePath
- The XML file to transform.transformer
- A pre-compiled Transformer
used to produce transformed output.
public static final String transformFile(File inputFile, Transformer transformer)
Transformer
. Use getTransformer(String
xslFilePath)
to produce a reusable Transformer
for a given XSL stylesheet.
inputFile
- The XML file to transform.transformer
- A pre-compiled Transformer
used to produce transformed output.
public static final StringWriter transformFileToWriter(String inputFilePath, Transformer transformer)
Transformer
. Use getTransformer(String
xslFilePath)
to produce a reusable Transformer
for a given XSL stylesheet. To convert the resulting StringWriter to a
String, call StringWriter.toString().
inputFilePath
- The XML file to transform.transformer
- A pre-compiled Transformer
used to produce transformed output.
public static final String transformString(String xmlString, Transformer transformer)
Transformer
. Use getTransformer(String
xslFilePath)
to produce a reusable Transformer
for a given XSL stylesheet.
xmlString
- The XML String to transform.transformer
- A pre-compiled Transformer
used to produce transformed output.
public static final StringWriter transformStringToWriter(String xmlString, Transformer transformer)
Transformer
. Use getTransformer(String
xslFilePath)
to produce a reusable Transformer
for a given XSL stylesheet. To convert the resulting StringWriter to a
String, call StringWriter.toString().
xmlString
- The XML String to transform.transformer
- A pre-compiled Transformer
used to produce transformed output.
public static final String transformFile(String inputFilePath, String xslFilePath)
inputFilePath
- The XML file to transform.xslFilePath
- The XSL file used to perform the transform.
public static final StringWriter transformFileToWriter(String inputFilePath, String xslFilePath)
inputFilePath
- The XML file to transform.xslFilePath
- The XSL file used to perform the transform.
public static final String transformString(String xmlString, String xslFilePath)
xmlString
- The XML String to transform.xslFilePath
- The XSL file used to perform the transform.
public static final StringWriter transformStringToWriter(String xmlString, String xslFilePath)
xmlString
- The XML String to transform.xslFilePath
- The XSL file used to perform the transform.
public static final Transformer getTransformer(String xslFilePath) throws TransformerConfigurationException, FileNotFoundException
Transformer
used to transform XML using
a given XSL stylesheet. For efficiency, one Transformer
should be used to transform multiple XMLs
from a single stylesheet.
xslFilePath
- A path to an XSL stylesheet
file.
TransformerConfigurationException
- If error.
FileNotFoundException
- If file can not be found.public static String encodeStringIntoHex(String stg)
Excepted chars include digits, letters and: - _ . %
Note: Unix commands cannot include the following chars: * ? ! | \ / ' " { } < > ; , ^ ( ) $ ~ Windows file names may not contain: \ / : * ? " < > |
stg
- A String to encode.
public static String encodeCharsInString(String stg)
Unix commands cannot include the following chars: * ? ! | \ / ' " { } < > ; , ^ ( ) $ ~
Windows file names may not contain: \ / : * ? " < > |
stg
- A String to encode.
|
DLESE Tools v1.2 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |