use of org.mycore.common.xsl.MCRParameterCollector 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();
}
use of org.mycore.common.xsl.MCRParameterCollector in project mycore by MyCoRe-Org.
the class MCRMetsIIIFPresentationImpl method getMets.
public Document getMets(String id) throws IOException, JDOMException, SAXException {
String objectid = MCRLinkTableManager.instance().getSourceOf(id).iterator().next();
MCRContentTransformer transformer = getTransformer();
MCRParameterCollector parameter = new MCRParameterCollector();
if (objectid != null && objectid.length() != 0) {
MCRDerivate derObj = MCRMetadataManager.retrieveMCRDerivate(MCRObjectID.getInstance(id));
MCRObjectID ownerID = derObj.getOwnerID();
objectid = ownerID.toString();
parameter.setParameter("objectID", objectid);
parameter.setParameter("derivateID", id);
}
MCRPath metsPath = MCRPath.getPath(id, "mets.xml");
if (!Files.exists(metsPath)) {
throw new MCRException("File not found: " + id);
}
MCRPathContent source = new MCRPathContent(metsPath);
MCRContent content = transformer instanceof MCRParameterizedTransformer ? ((MCRParameterizedTransformer) transformer).transform(source, parameter) : transformer.transform(source);
return content.asXML();
}
Aggregations