use of com.tyndalehouse.step.core.xsl.XslConversionType in project step by STEPBible.
the class JSwordPassageServiceImpl method executeStyleSheet.
/**
* Executes the stylesheet
*
* @param masterVersification the versification of the top line
* @param options the list of options to pass in
* @param interlinearVersion the interlinear version(s)
* @param bookData the book data, containing book and reference
* @param osissep the XML SAX provider
* @param displayMode the display mode
* @return a Transforming SAX event provider, from which can be transformed into HTML
* @throws TransformerException an exception in the stylesheet that is being executed
*/
private TransformingSAXEventProvider executeStyleSheet(final Versification masterVersification, final List<LookupOption> options, final String interlinearVersion, final BookData bookData, final SAXEventProvider osissep, final InterlinearMode displayMode, final String userLanguage) throws TransformerException {
final XslConversionType requiredTransformation = identifyStyleSheet(options, displayMode);
return (TransformingSAXEventProvider) new Converter() {
@Override
public SAXEventProvider convert(final SAXEventProvider provider) throws TransformerException {
try {
final String file = requiredTransformation.getFile();
final URI resourceURI = getClass().getResource(file).toURI();
final TransformingSAXEventProvider tsep = new TransformingSAXEventProvider(resourceURI, osissep);
// set parameters here
String changeVersion = "";
if (userLanguage.toLowerCase().startsWith("es"))
changeVersion = "SpaRV1909";
else if (userLanguage.equalsIgnoreCase("zh"))
changeVersion = "CUns";
else if (userLanguage.equalsIgnoreCase("zh_tw"))
changeVersion = "CUn";
else if (userLanguage.toLowerCase().startsWith("bg"))
changeVersion = "BulProtRev";
else if (userLanguage.toLowerCase().startsWith("hi"))
changeVersion = "HinULB";
if (changeVersion.length() > 0) {
tsep.setParameter("defaultVersion", changeVersion);
}
setOptions(tsep, options, bookData.getBooks());
setInterlinearOptions(tsep, bookData.getBooks()[0].getInitials(), masterVersification, getInterlinearVersion(interlinearVersion), bookData.getKey().getOsisID(), displayMode, bookData.getKey(), options);
setInterleavingOptions(tsep, displayMode, bookData);
return tsep;
} catch (final URISyntaxException e) {
throw new StepInternalException("Failed to load resource correctly", e);
}
}
}.convert(osissep);
}
Aggregations