|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.common.xml.MCRXSLTransformation
public class MCRXSLTransformation
This class implements XSLTransformation functions to be used in all other MyCoRe packages. The class is implemented as singleton and should be very easy to use. So here is an example:
// Get an instance of the class
MCRXSLTransformation transformation = MCRXSLTransformation.getInstance();
// Get the template: myStylesheet could be a String (i.e. a filename),
// a File or a StreamSource Templates
templates = transformation.getStylesheet(myStylesheet);
// Next, you are in need of a TransformerHandler:
TransformerHandler th = transformation.getTransformerHandler(templates);
// Now you are able to set some properties (if you want!):
Properties parameters = new Properties(); ...
transformation.setParameters(th, parameters);
// Finally, you need an OutputStream and might get at work:
OutputStream out = response.getOutputStream();
transformation.transform(jdom, th, out);
// You might also want to transform into something different, perhaps a ZIP-File:
OutputStream out = new ZipOutputStream(response.getOutputStream());
((ZipOutputStream) out).setLevel(Deflater.BEST_COMPRESSION);
ZipEntry ze = new ZipEntry("_index.htm");
((ZipOutputStream) out).putNextEntry(ze); ...
// After all this work is done, you could close the OutputStream:
out.close();
// This is not done by transform, the later example
// should show, why. *
| Constructor Summary | |
|---|---|
MCRXSLTransformation()
|
|
| Method Summary | |
|---|---|
static MCRXSLTransformation |
getInstance()
Method getInstance. |
Templates |
getStylesheet(File stylesheet)
Method getStylesheet. |
Templates |
getStylesheet(Source stylesheet)
Method getStylesheet. |
Templates |
getStylesheet(String stylesheet)
Method getStylesheet. |
TransformerHandler |
getTransformerHandler(Templates stylesheet)
Method getTransformerHandler. |
static void |
setParameters(TransformerHandler handler,
Map parameters)
Method setParameters. |
static void |
setParameters(Transformer transformer,
Map parameters)
Method setParameters. |
static Document |
transform(Document in,
Source stylesheet,
Map parameters)
Method transform. |
static Document |
transform(Document in,
String stylesheet)
Method transform. |
static Document |
transform(Document in,
String stylesheet,
Map parameters)
Method transform. |
static Document |
transform(Document in,
Transformer transformer)
transforms a jdom Document via XSLT. |
void |
transform(Document in,
TransformerHandler handler,
OutputStream out)
Method transform. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MCRXSLTransformation()
| Method Detail |
|---|
public static MCRXSLTransformation getInstance()
public Templates getStylesheet(String stylesheet)
stylesheet - Full path to the stylesheet
public Templates getStylesheet(File stylesheet)
stylesheet - A File with the stylesheet code
public Templates getStylesheet(Source stylesheet)
stylesheet - A StreamSource
public TransformerHandler getTransformerHandler(Templates stylesheet)
stylesheet -
public static void setParameters(TransformerHandler handler,
Map parameters)
handler - parameters -
public static void setParameters(Transformer transformer,
Map parameters)
public void transform(Document in,
TransformerHandler handler,
OutputStream out)
in - handler - out -
public static Document transform(Document in,
String stylesheet)
in - A JDOM-Document.stylesheet - The Filename with complete path (this is not a servlet!) of
the stylesheet.
public static Document transform(Document in,
String stylesheet,
Map parameters)
in - A JDOM-Document.stylesheet - The Filename with complete path (this is not a servlet!) of
the stylesheet.parameters - parameters used by the stylesheet for transformation
public static Document transform(Document in,
Source stylesheet,
Map parameters)
in - A JDOM-Document.stylesheet - The Filename with complete path (this is not a servlet!) of
the stylesheet.parameters - parameters used by the stylesheet for transformation
public static Document transform(Document in,
Transformer transformer)
throws TransformerException
in - Document inputtransformer - Transformer handling the transformation process
TransformerException - if transformation fails
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||