Search in sources :

Example 1 with MCRXSL2XMLTransformer

use of org.mycore.common.content.transformer.MCRXSL2XMLTransformer in project mycore by MyCoRe-Org.

the class MCRMailer method transform.

/**
 * Transforms the given input element using xsl stylesheet.
 *
 * @param input the input document to transform.
 * @param stylesheet the name of the xsl stylesheet to use, without the ".xsl" ending.
 * @param parameters the optionally empty table of xsl parameters
 * @return the output document generated by the transformation process
 */
private static Document transform(Document input, String stylesheet, Map<String, String> parameters) throws Exception {
    MCRJDOMContent source = new MCRJDOMContent(input);
    MCRXSL2XMLTransformer transformer = MCRXSL2XMLTransformer.getInstance("xsl/" + stylesheet + ".xsl");
    MCRParameterCollector parameterCollector = MCRParameterCollector.getInstanceFromUserSession();
    parameterCollector.setParameters(parameters);
    MCRContent result = transformer.transform(source, parameterCollector);
    return result.asXML();
}
Also used : MCRXSL2XMLTransformer(org.mycore.common.content.transformer.MCRXSL2XMLTransformer) MCRParameterCollector(org.mycore.common.xsl.MCRParameterCollector) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) MCRContent(org.mycore.common.content.MCRContent)

Aggregations

MCRContent (org.mycore.common.content.MCRContent)1 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)1 MCRXSL2XMLTransformer (org.mycore.common.content.transformer.MCRXSL2XMLTransformer)1 MCRParameterCollector (org.mycore.common.xsl.MCRParameterCollector)1