use of uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager in project OpenOLAT by OpenOLAT.
the class AssessmentObjectComponentRenderer method transformMathmlAsString.
protected void transformMathmlAsString(StringOutput sb, String mathmlAsString) {
if (!StringHelper.containsNonWhitespace(mathmlAsString)) {
return;
}
XsltStylesheetManager stylesheetManager = CoreSpringFactory.getImpl(QTI21Service.class).getXsltStylesheetManager();
final TransformerHandler mathmlTransformerHandler = stylesheetManager.getCompiledStylesheetHandler(ctopXsltUri, null);
try {
mathmlTransformerHandler.setResult(new StreamResult(sb));
final XMLReader xmlReader = XmlUtilities.createNsAwareSaxReader();
xmlReader.setContentHandler(mathmlTransformerHandler);
Reader mathStream = new StringReader(mathmlAsString);
InputSource assessmentSaxSource = new InputSource(mathStream);
xmlReader.parse(assessmentSaxSource);
} catch (final Exception e) {
log.error("Rendering XSLT pipeline failed for request {}", e);
sb.append("<span class='o_error'>ERROR MATHML</span>");
}
}
use of uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager in project openolat by klemens.
the class AssessmentObjectComponentRenderer method transformMathmlAsString.
protected void transformMathmlAsString(StringOutput sb, String mathmlAsString) {
if (!StringHelper.containsNonWhitespace(mathmlAsString)) {
return;
}
XsltStylesheetManager stylesheetManager = CoreSpringFactory.getImpl(QTI21Service.class).getXsltStylesheetManager();
final TransformerHandler mathmlTransformerHandler = stylesheetManager.getCompiledStylesheetHandler(ctopXsltUri, null);
try {
mathmlTransformerHandler.setResult(new StreamResult(sb));
final XMLReader xmlReader = XmlUtilities.createNsAwareSaxReader();
xmlReader.setContentHandler(mathmlTransformerHandler);
Reader mathStream = new StringReader(mathmlAsString);
InputSource assessmentSaxSource = new InputSource(mathStream);
xmlReader.parse(assessmentSaxSource);
} catch (final Exception e) {
log.error("Rendering XSLT pipeline failed for request {}", e);
sb.append("<span class='o_error'>ERROR MATHML</span>");
}
}
use of uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager in project OpenOLAT by OpenOLAT.
the class QTI21ServiceImpl method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
final List<JqtiExtensionPackage<?>> extensionPackages = new ArrayList<JqtiExtensionPackage<?>>();
/* Enable MathAssess extensions if requested */
if (qtiModule.isMathAssessExtensionEnabled()) {
log.info("Enabling the MathAssess extensions");
extensionPackages.add(new MathAssessExtensionPackage(xsltStylesheetCache));
extensionPackages.add(new OpenOLATExtensionPackage(xsltStylesheetCache));
}
jqtiExtensionManager = new JqtiExtensionManager(extensionPackages);
xsltStylesheetManager = new XsltStylesheetManager(new ClassPathResourceLocator(), xsltStylesheetCache);
jqtiExtensionManager.init();
Cacher cacher = coordinatorManager.getInstance().getCoordinator().getCacher();
assessmentTestsCache = cacher.getCache("QTIWorks", "assessmentTests");
assessmentItemsCache = cacher.getCache("QTIWorks", "assessmentItems");
}
use of uk.ac.ed.ph.jqtiplus.xmlutils.xslt.XsltStylesheetManager in project openolat by klemens.
the class QTI21ServiceImpl method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
final List<JqtiExtensionPackage<?>> extensionPackages = new ArrayList<JqtiExtensionPackage<?>>();
/* Enable MathAssess extensions if requested */
if (qtiModule.isMathAssessExtensionEnabled()) {
log.info("Enabling the MathAssess extensions");
extensionPackages.add(new MathAssessExtensionPackage(xsltStylesheetCache));
extensionPackages.add(new OpenOLATExtensionPackage(xsltStylesheetCache));
}
jqtiExtensionManager = new JqtiExtensionManager(extensionPackages);
xsltStylesheetManager = new XsltStylesheetManager(new ClassPathResourceLocator(), xsltStylesheetCache);
jqtiExtensionManager.init();
Cacher cacher = coordinatorManager.getInstance().getCoordinator().getCacher();
assessmentTestsCache = cacher.getCache("QTIWorks", "assessmentTests");
assessmentItemsCache = cacher.getCache("QTIWorks", "assessmentItems");
}
Aggregations