mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
xr 2 pdf
This commit is contained in:
parent
b6ff9d0b28
commit
bdbedfa799
1 changed files with 15 additions and 5 deletions
|
|
@ -82,13 +82,23 @@ public class TransformHandler extends BaseHandler {
|
|||
try ( final ByteArrayOutputStream out = new ByteArrayOutputStream() ) {
|
||||
Processor processor = new Processor(false);
|
||||
XsltCompiler xsltCompiler = processor.newXsltCompiler();
|
||||
|
||||
// 1. XSLT -> XR
|
||||
XsltExecutable stylesheet = xsltCompiler.compile(new StreamSource(new File("visualization/xsl/ubl-invoice-xr.xsl")));
|
||||
Serializer serializer = processor.newSerializer(out);
|
||||
serializer.setOutputProperty(Serializer.Property.METHOD, "html");
|
||||
serializer.setOutputProperty(Serializer.Property.INDENT, "yes");
|
||||
Xslt30Transformer transformer = stylesheet.load30();
|
||||
transformer.transform(source, serializer);
|
||||
return out.toByteArray();
|
||||
transformer.transform(source, processor.newSerializer(out));
|
||||
|
||||
// 2. XR -> HTML
|
||||
XsltExecutable htmlStylesheet = xsltCompiler.compile(new StreamSource(new File("visualization/xsl/xrechnung-html.xsl")));
|
||||
Xslt30Transformer htmlTransformer = htmlStylesheet.load30();
|
||||
|
||||
try ( final ByteArrayOutputStream htmlOut = new ByteArrayOutputStream() ) {
|
||||
// Use the XR output as the input for the HTML transformation
|
||||
htmlTransformer.transform(new StreamSource(new ByteArrayInputStream(out.toByteArray())), processor.newSerializer(htmlOut));
|
||||
|
||||
// Return the HTML output
|
||||
return htmlOut.toByteArray();
|
||||
}
|
||||
} catch (final IOException | SaxonApiException e) {
|
||||
Printer.writeOut("Error serializeXR2HTML IOException result", e);
|
||||
throw new IllegalStateException("Can not serialize result", e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue