use of net.sf.saxon.s9api.Serializer in project sirix by sirixdb.
the class XMLReduce method reduce.
@Override
public void reduce(final DateWritable paramKey, final Iterable<Text> paramValue, final Context paramContext) throws IOException, InterruptedException {
final StringBuilder builder = new StringBuilder("<root>");
for (final Text event : paramValue) {
System.out.println(event.toString());
builder.append(event.toString());
}
builder.append("</root>");
// System.out.println(builder.toString());
final Processor proc = new Processor(false);
final XsltCompiler compiler = proc.newXsltCompiler();
try {
final XsltExecutable exec = compiler.compile(new StreamSource(new File(STYLESHEET)));
final XsltTransformer transform = exec.load();
transform.setSource(new StreamSource(new StringReader(builder.toString())));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final Serializer serializer = new Serializer();
serializer.setOutputStream(out);
transform.setDestination(serializer);
transform.transform();
final String value = out.toString();
// System.out.println(value);
paramContext.write(null, new Text(value));
} catch (final SaxonApiException e) {
LOGWRAPPER.error(e);
}
}
Aggregations