use of javax.xml.transform.Result in project ddf by codice.
the class XMLUtils method format.
/**
* Formats XML into a String
*
* @param sourceXml to transform a given Source
* @param transformProperties settings for transformer
* @return XML string
*/
public static String format(Source sourceXml, TransformerProperties transformProperties) {
Writer buffer = new StringWriter();
Result streamResult = new StreamResult(buffer);
transformation(sourceXml, transformProperties, streamResult);
return buffer.toString();
}
use of javax.xml.transform.Result in project dhis2-core by dhis2.
the class DefaultHelpManager method getHelpItems.
@Override
public void getHelpItems(OutputStream out, Locale locale) {
try {
ClassPathResource classPathResource = resolveHelpFileResource(locale);
Source source = new StreamSource(classPathResource.getInputStream(), ENCODING_UTF8);
Result result = new StreamResult(out);
getTransformer("helpitems_stylesheet.xsl").transform(source, result);
} catch (Exception ex) {
throw new RuntimeException("Failed to get help content", ex);
}
}
use of javax.xml.transform.Result in project dhis2-core by dhis2.
the class DefaultHelpManager method getHelpContent.
// -------------------------------------------------------------------------
// HelpManager implementation
// -------------------------------------------------------------------------
@Override
public void getHelpContent(OutputStream out, String id, Locale locale) {
try {
ClassPathResource classPathResource = resolveHelpFileResource(locale);
Source source = new StreamSource(classPathResource.getInputStream(), ENCODING_UTF8);
Result result = new StreamResult(out);
Transformer transformer = getTransformer("help_stylesheet.xsl");
transformer.setParameter("sectionId", id);
transformer.transform(source, result);
} catch (Exception ex) {
throw new RuntimeException("Failed to get help content", ex);
}
}
Aggregations