Merge branch 'master' of github.com:ZUGFeRD/mustangproject
# Conflicts: # library/src/test/java/org/mustangproject/ZUGFeRD/ZF2PushTest.java
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package org.mustangproject.commandline;
|
package org.mustangproject.commandline;
|
||||||
|
|
||||||
import org.apache.commons.cli.*;
|
import org.apache.commons.cli.*;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.mustangproject.CII.CIIToUBL;
|
import org.mustangproject.CII.CIIToUBL;
|
||||||
import org.mustangproject.EStandard;
|
import org.mustangproject.EStandard;
|
||||||
import org.mustangproject.FileAttachment;
|
import org.mustangproject.FileAttachment;
|
||||||
@@ -84,6 +85,7 @@ public class Main {
|
|||||||
+ " [--logAppend <text>]: text to be added to log line\n"
|
+ " [--logAppend <text>]: text to be added to log line\n"
|
||||||
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
||||||
+ " [--source <filename>]: input PDF or XML file\n"
|
+ " [--source <filename>]: input PDF or XML file\n"
|
||||||
|
+ " [--log-as-pdf]: save log output as pdf\n"
|
||||||
+ " --action validateExpectInvalid validate directory expecting negative results \n"
|
+ " --action validateExpectInvalid validate directory expecting negative results \n"
|
||||||
+ " [--no-notices]: refrain from reporting notices\n"
|
+ " [--no-notices]: refrain from reporting notices\n"
|
||||||
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
+ " Additional parameters (optional - user will be prompted if not defined)\n"
|
||||||
@@ -357,6 +359,7 @@ public class Main {
|
|||||||
options.addOption(new Option("d", "directory", true, "which directory to operate on"));
|
options.addOption(new Option("d", "directory", true, "which directory to operate on"));
|
||||||
options.addOption(new Option("i", "ignorefileextension", false, "ignore non-matching file extensions"));
|
options.addOption(new Option("i", "ignorefileextension", false, "ignore non-matching file extensions"));
|
||||||
options.addOption(new Option("l", "listfromstdin", false, "take list of files from commandline"));
|
options.addOption(new Option("l", "listfromstdin", false, "take list of files from commandline"));
|
||||||
|
options.addOption(new Option("log-as-pdf", "log-as-pdf", false, "saving log output to pdf file"));
|
||||||
|
|
||||||
boolean optionsRecognized = false;
|
boolean optionsRecognized = false;
|
||||||
String action = "";
|
String action = "";
|
||||||
@@ -380,6 +383,7 @@ public class Main {
|
|||||||
String format = cmd.getOptionValue("format");
|
String format = cmd.getOptionValue("format");
|
||||||
String lang = cmd.getOptionValue("language");
|
String lang = cmd.getOptionValue("language");
|
||||||
Boolean noNotices = cmd.hasOption("no-notices");
|
Boolean noNotices = cmd.hasOption("no-notices");
|
||||||
|
Boolean LogAsPDF = cmd.hasOption("log-as-pdf");
|
||||||
|
|
||||||
String zugferdVersion = cmd.getOptionValue("version");
|
String zugferdVersion = cmd.getOptionValue("version");
|
||||||
String zugferdProfile = cmd.getOptionValue("profile");
|
String zugferdProfile = cmd.getOptionValue("profile");
|
||||||
@@ -427,7 +431,7 @@ public class Main {
|
|||||||
performUBL(sourceName, outName);
|
performUBL(sourceName, outName);
|
||||||
optionsRecognized = true;
|
optionsRecognized = true;
|
||||||
} else if ((action != null) && (action.equals("validate"))) {
|
} else if ((action != null) && (action.equals("validate"))) {
|
||||||
optionsRecognized = performValidate(sourceName, noNotices, cmd.getOptionValue("logAppend"));
|
optionsRecognized = performValidate(sourceName, noNotices, cmd.getOptionValue("logAppend"), LogAsPDF);
|
||||||
} else if ((action != null) && (action.equals("validateExpectValid"))) {
|
} else if ((action != null) && (action.equals("validateExpectValid"))) {
|
||||||
optionsRecognized = performValidateExpect(true, directoryName);
|
optionsRecognized = performValidateExpect(true, directoryName);
|
||||||
} else if ((action != null) && (action.equals("validateExpectInvalid"))) {
|
} else if ((action != null) && (action.equals("validateExpectInvalid"))) {
|
||||||
@@ -454,7 +458,7 @@ public class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean performValidate(String sourceName, boolean noNotices, String logAppend) {
|
private static boolean performValidate(String sourceName, boolean noNotices, String logAppend, boolean createLogAsPDF) {
|
||||||
boolean optionsRecognized;
|
boolean optionsRecognized;
|
||||||
if (sourceName == null) {
|
if (sourceName == null) {
|
||||||
sourceName = getFilenameFromUser("Source PDF or XML", "invoice.pdf", "pdf|xml", true, false);
|
sourceName = getFilenameFromUser("Source PDF or XML", "invoice.pdf", "pdf|xml", true, false);
|
||||||
@@ -466,7 +470,16 @@ public class Main {
|
|||||||
if (noNotices) {
|
if (noNotices) {
|
||||||
zfv.disableNotices();
|
zfv.disableNotices();
|
||||||
}
|
}
|
||||||
System.out.println(zfv.validate(sourceName));
|
|
||||||
|
String validationResultXML = zfv.validate(sourceName);
|
||||||
|
System.out.println(validationResultXML);
|
||||||
|
|
||||||
|
if( createLogAsPDF) {
|
||||||
|
ValidationLogVisualizer vlvi = new ValidationLogVisualizer();
|
||||||
|
String fileBasename = FilenameUtils.getBaseName(sourceName);
|
||||||
|
|
||||||
|
vlvi.toPDF(validationResultXML, fileBasename + "_result.pdf");
|
||||||
|
}
|
||||||
optionsRecognized = !zfv.hasOptionsError();
|
optionsRecognized = !zfv.hasOptionsError();
|
||||||
if (!zfv.wasCompletelyValid()) {
|
if (!zfv.wasCompletelyValid()) {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
|
|||||||
@@ -200,21 +200,51 @@
|
|||||||
</manifest>
|
</manifest>
|
||||||
<manifestSections>
|
<manifestSections>
|
||||||
<manifestSection>
|
<manifestSection>
|
||||||
<name>FreeSans.ttf</name>
|
<name>SourceSansPro-Regular.ttf</name>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Content-Type>font/ttf</Content-Type>
|
<Content-Type>font/ttf</Content-Type>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</manifestSection>
|
</manifestSection>
|
||||||
<manifestSection>
|
<manifestSection>
|
||||||
<name>FreeSerif.ttf</name>
|
<name>SourceSansPro-It.ttf</name>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Content-Type>application/x-font</Content-Type>
|
<Content-Type>font/ttf</Content-Type>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</manifestSection>
|
</manifestSection>
|
||||||
<manifestSection>
|
<manifestSection>
|
||||||
<name>Times-Bold.ttf</name>
|
<name>SourceSansPro-Bold.ttf</name>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Content-Type>application/x-font</Content-Type>
|
<Content-Type>font/ttf</Content-Type>
|
||||||
|
</manifestEntries>
|
||||||
|
</manifestSection>
|
||||||
|
<manifestSection>
|
||||||
|
<name>SourceSansPro-BoldIt.ttf</name>
|
||||||
|
<manifestEntries>
|
||||||
|
<Content-Type>font/ttf</Content-Type>
|
||||||
|
</manifestEntries>
|
||||||
|
</manifestSection>
|
||||||
|
<manifestSection>
|
||||||
|
<name>SourceSerifPro-Regular.ttf</name>
|
||||||
|
<manifestEntries>
|
||||||
|
<Content-Type>font/ttf</Content-Type>
|
||||||
|
</manifestEntries>
|
||||||
|
</manifestSection>
|
||||||
|
<manifestSection>
|
||||||
|
<name>SourceSerifPro-It.ttf</name>
|
||||||
|
<manifestEntries>
|
||||||
|
<Content-Type>font/ttf</Content-Type>
|
||||||
|
</manifestEntries>
|
||||||
|
</manifestSection>
|
||||||
|
<manifestSection>
|
||||||
|
<name>SourceSerifPro-Bold.ttf</name>
|
||||||
|
<manifestEntries>
|
||||||
|
<Content-Type>font/ttf</Content-Type>
|
||||||
|
</manifestEntries>
|
||||||
|
</manifestSection>
|
||||||
|
<manifestSection>
|
||||||
|
<name>SourceSerifPro-BoldIt.ttf</name>
|
||||||
|
<manifestEntries>
|
||||||
|
<Content-Type>font/ttf</Content-Type>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</manifestSection>
|
</manifestSection>
|
||||||
</manifestSections>
|
</manifestSections>
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import org.apache.fop.apps.*;
|
||||||
|
import org.apache.fop.apps.io.ResourceResolverFactory;
|
||||||
|
import org.apache.fop.configuration.Configuration;
|
||||||
|
import org.apache.fop.configuration.ConfigurationException;
|
||||||
|
import org.apache.fop.configuration.DefaultConfigurationBuilder;
|
||||||
|
import org.apache.xmlgraphics.util.MimeConstants;
|
||||||
|
import org.mustangproject.ClasspathResolverURIAdapter;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.xml.transform.*;
|
||||||
|
import javax.xml.transform.sax.SAXResult;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class ValidationLogVisualizer {
|
||||||
|
public enum Language {
|
||||||
|
EN,
|
||||||
|
FR,
|
||||||
|
DE
|
||||||
|
}
|
||||||
|
|
||||||
|
static final ClassLoader CLASS_LOADER = ValidationLogVisualizer.class.getClassLoader();
|
||||||
|
private static final String RESOURCE_PATH = "";
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ValidationLogVisualizer.class);
|
||||||
|
|
||||||
|
private TransformerFactory mFactory = null;
|
||||||
|
private Templates mXsltPDFTemplate = null;
|
||||||
|
|
||||||
|
|
||||||
|
public ValidationLogVisualizer() {
|
||||||
|
mFactory = new net.sf.saxon.TransformerFactoryImpl();
|
||||||
|
// fact = TransformerFactory.newInstance();
|
||||||
|
mFactory.setURIResolver(new ValidationLogVisualizer.ClasspathResourceURIResolver());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyXSLTToPDF(final String xmlContent, final OutputStream PDFOutstream)
|
||||||
|
throws TransformerException {
|
||||||
|
Transformer transformer = mXsltPDFTemplate.newTransformer();
|
||||||
|
|
||||||
|
transformer.transform(new StreamSource(new StringReader(xmlContent)), new StreamResult(PDFOutstream));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String toFOP(final String xmlContent)
|
||||||
|
throws TransformerException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (mXsltPDFTemplate == null) {
|
||||||
|
mXsltPDFTemplate = mFactory.newTemplates(
|
||||||
|
new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/result-pdf.xsl")));
|
||||||
|
}
|
||||||
|
} catch (TransformerConfigurationException ex) {
|
||||||
|
LOGGER.error("Failed to init XSLT templates", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
applyXSLTToPDF(xmlContent, baos);
|
||||||
|
|
||||||
|
} catch (Exception e1) {
|
||||||
|
LOGGER.error("Failed to create PDF", e1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return baos.toString(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toPDF(String xmlLogfileContent, String pdfFilename) {
|
||||||
|
|
||||||
|
// the writing part
|
||||||
|
|
||||||
|
String result = null;
|
||||||
|
|
||||||
|
/* remove file endings so that tests can also pass after checking
|
||||||
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
result = this.toFOP(xmlLogfileContent);
|
||||||
|
} catch ( TransformerException e) {
|
||||||
|
LOGGER.error("Failed to apply FOP", e);
|
||||||
|
}
|
||||||
|
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
|
||||||
|
|
||||||
|
Configuration cfg = null;
|
||||||
|
try {
|
||||||
|
cfg = cfgBuilder.build(CLASS_LOADER.getResourceAsStream("fop-config.xconf"));
|
||||||
|
} catch (ConfigurationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
FopFactoryBuilder builder = new FopFactoryBuilder(new File(".").toURI(), new ClasspathResolverURIAdapter()).setConfiguration(cfg);
|
||||||
|
// Step 1: Construct a FopFactory by specifying a reference to the configuration file
|
||||||
|
// (reuse if you plan to render multiple documents!)
|
||||||
|
|
||||||
|
FopFactory fopFactory = builder.build();
|
||||||
|
|
||||||
|
fopFactory.getFontManager().setResourceResolver(
|
||||||
|
ResourceResolverFactory.createInternalResourceResolver(
|
||||||
|
new File(".").toURI(),
|
||||||
|
new ClasspathResolverURIAdapter()));
|
||||||
|
|
||||||
|
FOUserAgent userAgent = fopFactory.newFOUserAgent();
|
||||||
|
|
||||||
|
userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-3b");
|
||||||
|
|
||||||
|
// Step 2: Set up output stream.
|
||||||
|
// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
|
||||||
|
|
||||||
|
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(pdfFilename))) {
|
||||||
|
|
||||||
|
// Step 3: Construct fop with desired output format
|
||||||
|
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);
|
||||||
|
|
||||||
|
// Step 4: Setup JAXP using identity transformer
|
||||||
|
TransformerFactory factory = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = factory.newTransformer(); // identity transformer
|
||||||
|
|
||||||
|
// Step 5: Setup input and output for XSLT transformation
|
||||||
|
// Setup input stream
|
||||||
|
Source src = new StreamSource(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8)));
|
||||||
|
|
||||||
|
// Resulting SAX events (the generated FO) must be piped through to FOP
|
||||||
|
Result res = new SAXResult(fop.getDefaultHandler());
|
||||||
|
|
||||||
|
// Step 6: Start XSLT transformation and FOP processing
|
||||||
|
transformer.transform(src, res);
|
||||||
|
|
||||||
|
} catch (FOPException | IOException | TransformerException e) {
|
||||||
|
LOGGER.error("Failed to create PDF", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ClasspathResourceURIResolver implements URIResolver {
|
||||||
|
ClasspathResourceURIResolver() {
|
||||||
|
// Do nothing, just prevents synthetic access warning.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Source resolve(String href, String base) throws TransformerException {
|
||||||
|
return new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/" + href));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -659,6 +659,7 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
*
|
*
|
||||||
* @return a List of LineItem instances
|
* @return a List of LineItem instances
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<Item> getLineItemList() {
|
public List<Item> getLineItemList() {
|
||||||
final List<Node> nodeList = getLineItemNodes();
|
final List<Node> nodeList = getLineItemNodes();
|
||||||
final List<Item> lineItemList = new ArrayList<>();
|
final List<Item> lineItemList = new ArrayList<>();
|
||||||
|
|||||||
@@ -1036,6 +1036,7 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
* for PDF embedded files in FX use getFileAttachmentsPDF()
|
* for PDF embedded files in FX use getFileAttachmentsPDF()
|
||||||
* @deprecated use invoice.getAdditionalReferencedDocuments
|
* @deprecated use invoice.getAdditionalReferencedDocuments
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public List<FileAttachment> getFileAttachmentsXML() {
|
public List<FileAttachment> getFileAttachmentsXML() {
|
||||||
return new ArrayList<>(Arrays.asList(importedInvoice.getAdditionalReferencedDocuments()));
|
return new ArrayList<>(Arrays.asList(importedInvoice.getAdditionalReferencedDocuments()));
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
library/src/main/resources/fonts/SourceSansPro-Bold.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSansPro-Bold.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSansPro-BoldIt.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSansPro-BoldIt.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSansPro-It.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSansPro-It.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSansPro-Regular.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSansPro-Regular.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSerifPro-Bold.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSerifPro-Bold.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSerifPro-BoldIt.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSerifPro-BoldIt.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSerifPro-It.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSerifPro-It.ttf
Normal file
Binary file not shown.
BIN
library/src/main/resources/fonts/SourceSerifPro-Regular.ttf
Normal file
BIN
library/src/main/resources/fonts/SourceSerifPro-Regular.ttf
Normal file
Binary file not shown.
@@ -1,37 +1,57 @@
|
|||||||
<fop version="1.0">
|
<fop version="1.0">
|
||||||
|
|
||||||
<!-- Strict user configuration -->
|
<!-- Strict user configuration -->
|
||||||
<strict-configuration>true</strict-configuration>
|
<strict-configuration>true</strict-configuration>
|
||||||
|
|
||||||
<!-- Strict FO validation -->
|
<!-- Strict FO validation -->
|
||||||
<strict-validation>true</strict-validation>
|
<strict-validation>true</strict-validation>
|
||||||
|
|
||||||
<!-- Base URL for resolving relative URLs -->
|
<!-- Base URL for resolving relative URLs -->
|
||||||
|
|
||||||
<!-- Font Base URL for resolving relative font URLs -->
|
<!-- Font Base URL for resolving relative font URLs -->
|
||||||
|
|
||||||
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
|
<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
|
||||||
<source-resolution>96</source-resolution>
|
<source-resolution>96</source-resolution>
|
||||||
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
|
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
|
||||||
<target-resolution>96</target-resolution>
|
<target-resolution>96</target-resolution>
|
||||||
|
|
||||||
<!-- default page-height and page-width, in case
|
<!-- default page-height and page-width, in case
|
||||||
value is specified as auto -->
|
value is specified as auto -->
|
||||||
<default-page-settings height="297mm" width="210mm"/><!-- DIN A/4 -->
|
<default-page-settings height="297mm" width="210mm"/><!-- DIN A/4 -->
|
||||||
|
|
||||||
<!-- etc. etc..... -->
|
<!-- etc. etc..... -->
|
||||||
|
|
||||||
<renderers>
|
<renderers>
|
||||||
<renderer mime="application/pdf">
|
<renderer mime="application/pdf">
|
||||||
<fonts><!-- https://xmlgraphics.apache.org/fop/1.1/fonts.html auto-embed -->
|
<fonts>
|
||||||
<auto-detect/>
|
<!-- https://xmlgraphics.apache.org/fop/1.1/fonts.html auto-embed -->
|
||||||
<font kerning="no" embed-url="classpath:FreeSans.ttf" embedding-mode="subset">
|
<auto-detect/>
|
||||||
<font-triplet name="SourceSerifPro" style="normal" weight="normal" />
|
<font kerning="yes" embed-url="classpath:fonts/SourceSansPro-Regular.ttf" embedding-mode="subset">
|
||||||
<font-triplet name="Times-Bold" style="normal" weight="normal" />
|
<font-triplet name="SourceSansPro" style="normal" weight="400"/>
|
||||||
</font>
|
</font>
|
||||||
</fonts>
|
<font kerning="yes" embed-url="classpath:fonts/SourceSansPro-It.ttf" embedding-mode="subset">
|
||||||
<output-profile>classpath:AdobeCompat-v2.icc</output-profile>
|
<font-triplet name="SourceSansPro" style="italic" weight="400"/>
|
||||||
</renderer>
|
</font>
|
||||||
</renderers>
|
<font kerning="yes" embed-url="classpath:fonts/SourceSansPro-Bold.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSansPro" style="normal" weight="700"/>
|
||||||
</fop>
|
</font>
|
||||||
|
<font kerning="yes" embed-url="classpath:fonts/SourceSansPro-BoldIt.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSansPro" style="italic" weight="700"/>
|
||||||
|
</font>
|
||||||
|
<font kerning="yes" embed-url="classpath:fonts/SourceSerifPro-Regular.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSerifPro" style="normal" weight="400"/>
|
||||||
|
</font>
|
||||||
|
<font kerning="yes" embed-url="classpath:fonts/SourceSerifPro-It.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSerifPro" style="italic" weight="400"/>
|
||||||
|
</font>
|
||||||
|
<font kerning="yes" embed-url="classpath:fonts/SourceSerifPro-Bold.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSerifPro" style="normal" weight="700"/>
|
||||||
|
</font>
|
||||||
|
<font kerning="yes" embed-url="classpath:fonts/SourceSerifPro-BoldIt.ttf" embedding-mode="subset">
|
||||||
|
<font-triplet name="SourceSerifPro" style="italic" weight="700"/>
|
||||||
|
</font>
|
||||||
|
</fonts>
|
||||||
|
<output-profile>classpath:AdobeCompat-v2.icc</output-profile>
|
||||||
|
</renderer>
|
||||||
|
</renderers>
|
||||||
|
</fop>
|
||||||
|
|||||||
227
library/src/main/resources/stylesheets/result-pdf.xsl
Normal file
227
library/src/main/resources/stylesheets/result-pdf.xsl
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
|
||||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
version="2.0">
|
||||||
|
<!-- ==========================================================================
|
||||||
|
== Imports
|
||||||
|
=========================================================================== -->
|
||||||
|
<xsl:import href="common-xr.xsl"/>
|
||||||
|
|
||||||
|
<xsl:import href="xr-pdf/lib/konstanten.xsl"/>
|
||||||
|
|
||||||
|
<!-- FO engine used can be specified. Specific extensions will be then enabled.
|
||||||
|
Supported values are:
|
||||||
|
axf - Antenna House XSL Formatter
|
||||||
|
fop - Apache FOP
|
||||||
|
-->
|
||||||
|
<xsl:param name="foengine"/>
|
||||||
|
|
||||||
|
<xsl:param name="axf.extensions" select="if ($foengine eq 'axf') then true() else false()"/>
|
||||||
|
<xsl:param name="fop.extensions" select="if ($foengine eq 'fop') then true() else false()"/>
|
||||||
|
|
||||||
|
|
||||||
|
<xsl:variable name="xml_result_color">
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'valid' ">
|
||||||
|
<xsl:text>green</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'invalid' ">
|
||||||
|
<xsl:text>red</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="pdf_result_color">
|
||||||
|
<xsl:if test="/validation/pdf/summary/@status = 'valid' ">
|
||||||
|
<xsl:text>green</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="/validation/pdf/summary/@status = 'invalid' ">
|
||||||
|
<xsl:text>red</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="pdf_result_text">
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'valid' ">
|
||||||
|
<xsl:text>Das ZUGFeRD-PDF ist valide.</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'invalid' ">
|
||||||
|
<xsl:text>Das ZUGFeRD-PDF ist nicht valide.</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:variable name="result_text">
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'valid' ">
|
||||||
|
<xsl:text>Es wird empfohlen das Dokument anzunehmen und weiter zu verarbeiten.</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="/validation/xml/summary/@status = 'invalid' ">
|
||||||
|
<xsl:text>Es wird empfohlen das Dokument zurückzuweisen.</xsl:text>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
<xsl:template match="validation">
|
||||||
|
<fo:root xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"
|
||||||
|
language="{$lang}" font-family="{$fontSans}">
|
||||||
|
<fo:layout-master-set>
|
||||||
|
<fo:simple-page-master master-name="DIN-A4" page-height="297mm" page-width="210mm">
|
||||||
|
<fo:region-body region-name="body" margin="20mm 10mm 20mm 20mm" />
|
||||||
|
</fo:simple-page-master>
|
||||||
|
</fo:layout-master-set>
|
||||||
|
|
||||||
|
<fo:page-sequence master-reference="DIN-A4">
|
||||||
|
<fo:flow flow-name="body">
|
||||||
|
<fo:block font-size="24px" font-weight="bold">
|
||||||
|
Prüfbericht
|
||||||
|
</fo:block>
|
||||||
|
|
||||||
|
<xsl:call-template name="SubHeader">
|
||||||
|
<xsl:with-param name="text" select='"Angaben zum geprüften Dokument"' />
|
||||||
|
<xsl:with-param name="color" select='"black"' />
|
||||||
|
</xsl:call-template>
|
||||||
|
|
||||||
|
<fo:block>
|
||||||
|
<fo:block text-align="justify">
|
||||||
|
<fo:float float="right">
|
||||||
|
<fo:block >
|
||||||
|
<xsl:value-of select="/validation/@filename" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:float>
|
||||||
|
Referenz:
|
||||||
|
</fo:block>
|
||||||
|
</fo:block>
|
||||||
|
<fo:block>
|
||||||
|
<fo:block text-align="justify">
|
||||||
|
<fo:float float="right">
|
||||||
|
<fo:block >
|
||||||
|
<xsl:value-of select="/validation/@datetime" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:float>
|
||||||
|
Zeitpunkt der Prüfung:
|
||||||
|
</fo:block>
|
||||||
|
</fo:block>
|
||||||
|
<fo:block>
|
||||||
|
<fo:block text-align="justify">
|
||||||
|
<fo:float float="right">
|
||||||
|
<fo:block >
|
||||||
|
<xsl:value-of select="/validation/xml/info/profile" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:float>
|
||||||
|
Erkannter Dokumenttyp:
|
||||||
|
</fo:block>
|
||||||
|
</fo:block>
|
||||||
|
|
||||||
|
<xsl:apply-templates select="/validation/pdf" />
|
||||||
|
|
||||||
|
<!--<xsl:call-template name="SubHeader" >
|
||||||
|
<xsl:with-param name="text" select='"Konformitätsprüfung:"' />
|
||||||
|
<xsl:with-param name="color" select='"black"' />
|
||||||
|
</xsl:call-template>-->
|
||||||
|
|
||||||
|
<xsl:call-template name="SubHeader" >
|
||||||
|
<xsl:with-param name="text" select="concat('Bewertung: ', $result_text)" />
|
||||||
|
<xsl:with-param name="color" select="$xml_result_color" />
|
||||||
|
</xsl:call-template>
|
||||||
|
|
||||||
|
<fo:block>Validierungsergebnisse im Detail:</fo:block>
|
||||||
|
|
||||||
|
<fo:table>
|
||||||
|
<fo:table-column border-style="solid" />
|
||||||
|
<fo:table-column border-style="solid" />
|
||||||
|
<fo:table-column border-style="solid" />
|
||||||
|
<fo:table-column column-width="70%" border-style="solid" />
|
||||||
|
<fo:table-header>
|
||||||
|
<fo:table-row background-color="#E0E0E0" font-weight="bold">
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>Type</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>Code</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>Schwere</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>Text</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
</fo:table-row>
|
||||||
|
</fo:table-header>
|
||||||
|
<fo:table-body>
|
||||||
|
<xsl:apply-templates select="/validation/xml/messages" />
|
||||||
|
</fo:table-body>
|
||||||
|
</fo:table>
|
||||||
|
|
||||||
|
</fo:flow>
|
||||||
|
</fo:page-sequence>
|
||||||
|
</fo:root>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="notice|error">
|
||||||
|
<fo:table-row font-size="12px" border-style="solid">
|
||||||
|
<fo:table-cell number-rows-spanned="2">
|
||||||
|
<fo:block>
|
||||||
|
<xsl:value-of select="@type" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell number-rows-spanned="2">
|
||||||
|
<fo:block>
|
||||||
|
<xsl:call-template name="SUBID" >
|
||||||
|
<xsl:with-param name="myparam" select="substring-after(.,' [ID ')" />
|
||||||
|
</xsl:call-template>
|
||||||
|
</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell number-rows-spanned="2">
|
||||||
|
<fo:block >
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="name() = 'error'">
|
||||||
|
<xsl:attribute name="color">red</xsl:attribute>
|
||||||
|
Fehler
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
Hinweis
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>
|
||||||
|
<xsl:if test="name() = 'error'">
|
||||||
|
<xsl:attribute name="color">red</xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:value-of select="substring-before(.,' [ID')" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
</fo:table-row>
|
||||||
|
<fo:table-row font-size="12px" border-style="solid">
|
||||||
|
<fo:table-cell>
|
||||||
|
<fo:block>
|
||||||
|
<xsl:if test="name() = 'error'">
|
||||||
|
<xsl:attribute name="color">red</xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
Pfad:
|
||||||
|
<xsl:value-of select="@location" />
|
||||||
|
</fo:block>
|
||||||
|
</fo:table-cell>
|
||||||
|
</fo:table-row>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="pdf">
|
||||||
|
<xsl:call-template name="SubHeader" >
|
||||||
|
<xsl:with-param name="text" select="concat('ZUGFeRD-PDF: ', $pdf_result_text)" />
|
||||||
|
<xsl:with-param name="color" select='"black"' />
|
||||||
|
</xsl:call-template>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="SubHeader">
|
||||||
|
<xsl:param name="text" />
|
||||||
|
<xsl:param name="color" />
|
||||||
|
<fo:block color="{$color}" background-color="#E0E0E0" margin-bottom="10px" padding="3px" font-weight="bold" margin-top="10px">
|
||||||
|
<xsl:value-of select="$text" />
|
||||||
|
</fo:block>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template name="SUBID">
|
||||||
|
<xsl:param name="myparam" />
|
||||||
|
<xsl:variable name="myparam.end" select="substring-before($myparam, ']')"/>
|
||||||
|
<xsl:value-of select="$myparam.end"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
||||||
@@ -1,235 +1,235 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format"
|
||||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
|
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
|
||||||
xmlns:xr="urn:ce.eu:en16931:2017:xoev-de:kosit:standard:xrechnung-1"
|
xmlns:xr="urn:ce.eu:en16931:2017:xoev-de:kosit:standard:xrechnung-1"
|
||||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:xrv="http://www.example.org/XRechnung-Viewer"
|
xmlns:xrv="http://www.example.org/XRechnung-Viewer"
|
||||||
xmlns:xrf="https://projekte.kosit.org/xrechnung/xrechnung-visualization/functions"
|
xmlns:xrf="https://projekte.kosit.org/xrechnung/xrechnung-visualization/functions"
|
||||||
version="2.0">
|
version="2.0">
|
||||||
|
|
||||||
<!-- ==========================================================================
|
<!-- ==========================================================================
|
||||||
== Schriften
|
== Schriften
|
||||||
=========================================================================== -->
|
=========================================================================== -->
|
||||||
|
|
||||||
<xsl:variable name="fontSans">SourceSerifPro</xsl:variable>
|
<xsl:variable name="fontSans">SourceSansPro</xsl:variable>
|
||||||
<xsl:variable name="fontSerif">SourceSerifPro</xsl:variable>
|
<xsl:variable name="fontSerif">SourceSerifPro</xsl:variable>
|
||||||
|
|
||||||
<xsl:variable name="amount-picture" select="xrf:_('amount-format')"/>
|
<xsl:variable name="amount-picture" select="xrf:_('amount-format')"/>
|
||||||
<xsl:variable name="percentage-picture" select="xrf:_('percentage-format')"/>
|
<xsl:variable name="percentage-picture" select="xrf:_('percentage-format')"/>
|
||||||
|
|
||||||
|
|
||||||
<!-- ==========================================================================
|
<!-- ==========================================================================
|
||||||
== Attribute-Sets
|
== Attribute-Sets
|
||||||
=========================================================================== -->
|
=========================================================================== -->
|
||||||
|
|
||||||
<!-- Fliesstext -->
|
<!-- Fliesstext -->
|
||||||
<xsl:attribute-set name="fliesstext">
|
<xsl:attribute-set name="fliesstext">
|
||||||
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="line-height">12pt</xsl:attribute>
|
<xsl:attribute name="line-height">12pt</xsl:attribute>
|
||||||
<xsl:attribute name="hyphenation-ladder-count">3</xsl:attribute>
|
<xsl:attribute name="hyphenation-ladder-count">3</xsl:attribute>
|
||||||
<xsl:attribute name="hyphenate">true</xsl:attribute>
|
<xsl:attribute name="hyphenate">true</xsl:attribute>
|
||||||
<xsl:attribute name="language">de</xsl:attribute>
|
<xsl:attribute name="language">de</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- H1 Marker -->
|
<!-- H1 Marker -->
|
||||||
<xsl:attribute-set name="marker">
|
<xsl:attribute-set name="marker">
|
||||||
<xsl:attribute name="font-size">18pt</xsl:attribute>
|
<xsl:attribute name="font-size">18pt</xsl:attribute>
|
||||||
<xsl:attribute name="font-family"><xsl:value-of select="$fontSerif"/></xsl:attribute>
|
<xsl:attribute name="font-family"><xsl:value-of select="$fontSerif"/></xsl:attribute>
|
||||||
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
||||||
<xsl:attribute name="span">all</xsl:attribute>
|
<xsl:attribute name="span">all</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- H1 -->
|
<!-- H1 -->
|
||||||
<xsl:attribute-set name="h1">
|
<xsl:attribute-set name="h1">
|
||||||
<xsl:attribute name="font-size">18pt</xsl:attribute>
|
<xsl:attribute name="font-size">18pt</xsl:attribute>
|
||||||
<xsl:attribute name="font-family"><xsl:value-of select="$fontSerif"/></xsl:attribute>
|
<xsl:attribute name="font-family"><xsl:value-of select="$fontSerif"/></xsl:attribute>
|
||||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||||
<xsl:attribute name="margin-bottom">4mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">4mm</xsl:attribute>
|
||||||
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
||||||
<xsl:attribute name="span">all</xsl:attribute>
|
<xsl:attribute name="span">all</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- H2-Container -->
|
<!-- H2-Container -->
|
||||||
<xsl:attribute-set name="h2-container">
|
<xsl:attribute-set name="h2-container">
|
||||||
<xsl:attribute name="border-top">0.5pt solid</xsl:attribute>
|
<xsl:attribute name="border-top">0.5pt solid</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">2.5pt</xsl:attribute>
|
<xsl:attribute name="padding-top">2.5pt</xsl:attribute>
|
||||||
<xsl:attribute name="span">all</xsl:attribute>
|
<xsl:attribute name="span">all</xsl:attribute>
|
||||||
<xsl:attribute name="margin-bottom">4mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">4mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- H2 -->
|
<!-- H2 -->
|
||||||
<xsl:attribute-set name="h2">
|
<xsl:attribute-set name="h2">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
||||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||||
<xsl:attribute name="border">0.5pt solid</xsl:attribute>
|
<xsl:attribute name="border">0.5pt solid</xsl:attribute>
|
||||||
<xsl:attribute name="padding">4pt 6pt</xsl:attribute>
|
<xsl:attribute name="padding">4pt 6pt</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
<xsl:attribute name="margin">0</xsl:attribute>
|
<xsl:attribute name="margin">0</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- H3 -->
|
<!-- H3 -->
|
||||||
<xsl:attribute-set name="h3">
|
<xsl:attribute-set name="h3">
|
||||||
<xsl:attribute name="font-size">10pt</xsl:attribute>
|
<xsl:attribute name="font-size">10pt</xsl:attribute>
|
||||||
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
<xsl:attribute name="font-family"><xsl:value-of select="$fontSans"/></xsl:attribute>
|
||||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||||
<xsl:attribute name="margin-bottom">1mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-top">2mm</xsl:attribute>
|
<xsl:attribute name="margin-top">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="span">all</xsl:attribute>
|
<xsl:attribute name="span">all</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- Separator -->
|
<!-- Separator -->
|
||||||
<xsl:attribute-set name="separator">
|
<xsl:attribute-set name="separator">
|
||||||
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-bottom">3mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">3mm</xsl:attribute>
|
||||||
<xsl:attribute name="border-bottom">0.5pt dotted</xsl:attribute>
|
<xsl:attribute name="border-bottom">0.5pt dotted</xsl:attribute>
|
||||||
<xsl:attribute name="color">#999999</xsl:attribute>
|
<xsl:attribute name="color">#999999</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- Wert-Felder -->
|
<!-- Wert-Felder -->
|
||||||
<xsl:variable name="wertHG">#eeeeee</xsl:variable>
|
<xsl:variable name="wertHG">#eeeeee</xsl:variable>
|
||||||
<xsl:variable name="wert-legende-breite">28</xsl:variable>
|
<xsl:variable name="wert-legende-breite">28</xsl:variable>
|
||||||
|
|
||||||
<xsl:attribute-set name="wert-legende">
|
<xsl:attribute-set name="wert-legende">
|
||||||
<xsl:attribute name="font-size">7pt</xsl:attribute>
|
<xsl:attribute name="font-size">7pt</xsl:attribute>
|
||||||
<xsl:attribute name="line-height">10pt</xsl:attribute>
|
<xsl:attribute name="line-height">10pt</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">1mm</xsl:attribute>
|
<xsl:attribute name="padding-top">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">1mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
<xsl:attribute name="margin-left">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="wert-ausgabe">
|
<xsl:attribute-set name="wert-ausgabe">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="line-height">10pt</xsl:attribute>
|
<xsl:attribute name="line-height">10pt</xsl:attribute>
|
||||||
<xsl:attribute name="background-color"><xsl:value-of select="$wertHG"/></xsl:attribute>
|
<xsl:attribute name="background-color"><xsl:value-of select="$wertHG"/></xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">1mm</xsl:attribute>
|
<xsl:attribute name="padding-top">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">1mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">2mm</xsl:attribute>
|
<xsl:attribute name="padding-left">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">2mm</xsl:attribute>
|
<xsl:attribute name="padding-right">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
|
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- Rechnung-Felder -->
|
<!-- Rechnung-Felder -->
|
||||||
<xsl:attribute-set name="rechnung-legende">
|
<xsl:attribute-set name="rechnung-legende">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">left</xsl:attribute>
|
<xsl:attribute name="text-align">left</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="rechnung-steuer">
|
<xsl:attribute-set name="rechnung-steuer">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">left</xsl:attribute>
|
<xsl:attribute name="text-align">left</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="rechnung-wert">
|
<xsl:attribute-set name="rechnung-wert">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">right</xsl:attribute>
|
<xsl:attribute name="text-align">right</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">0mm</xsl:attribute>
|
<xsl:attribute name="padding-right">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="rechnung-legende-summe">
|
<xsl:attribute-set name="rechnung-legende-summe">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">left</xsl:attribute>
|
<xsl:attribute name="text-align">left</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="rechnung-steuer-summe">
|
<xsl:attribute-set name="rechnung-steuer-summe">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">left</xsl:attribute>
|
<xsl:attribute name="text-align">left</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
||||||
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="rechnung-wert-summe">
|
<xsl:attribute-set name="rechnung-wert-summe">
|
||||||
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
<xsl:attribute name="font-size">9pt</xsl:attribute>
|
||||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||||
<xsl:attribute name="text-align">right</xsl:attribute>
|
<xsl:attribute name="text-align">right</xsl:attribute>
|
||||||
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
<xsl:attribute name="padding-top">0.4mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
<xsl:attribute name="padding-bottom">0.2mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
<xsl:attribute name="padding-left">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">0mm</xsl:attribute>
|
<xsl:attribute name="padding-right">0mm</xsl:attribute>
|
||||||
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
<xsl:attribute name="border-top">0.1pt solid #999999</xsl:attribute>
|
||||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- Box-Container -->
|
<!-- Box-Container -->
|
||||||
<xsl:attribute-set name="box-container-kapitel">
|
<xsl:attribute-set name="box-container-kapitel">
|
||||||
<xsl:attribute name="margin-bottom">10mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">10mm</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="box-container-bereich">
|
<xsl:attribute-set name="box-container-bereich">
|
||||||
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
||||||
<xsl:attribute name="keep-together.within-page">always</xsl:attribute>
|
<xsl:attribute name="keep-together.within-page">always</xsl:attribute>
|
||||||
<xsl:attribute name="span">all</xsl:attribute>
|
<xsl:attribute name="span">all</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="box-container-inner">
|
<xsl:attribute-set name="box-container-inner">
|
||||||
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<!-- Tabular invoice lines -->
|
<!-- Tabular invoice lines -->
|
||||||
<xsl:attribute-set name="invoicelines-table">
|
<xsl:attribute-set name="invoicelines-table">
|
||||||
<xsl:attribute name="padding-left">2pt</xsl:attribute>
|
<xsl:attribute name="padding-left">2pt</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">2pt</xsl:attribute>
|
<xsl:attribute name="padding-right">2pt</xsl:attribute>
|
||||||
<xsl:attribute name="width">100%</xsl:attribute>
|
<xsl:attribute name="width">100%</xsl:attribute>
|
||||||
<xsl:attribute name="table-layout">fixed</xsl:attribute>
|
<xsl:attribute name="table-layout">fixed</xsl:attribute>
|
||||||
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
<xsl:attribute name="margin-bottom">2mm</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="invoicelines-table-header">
|
<xsl:attribute-set name="invoicelines-table-header">
|
||||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="invoicelines-table-row">
|
<xsl:attribute-set name="invoicelines-table-row">
|
||||||
<!-- Nested sub-invoice lines will recursively decrease font-size -->
|
<!-- Nested sub-invoice lines will recursively decrease font-size -->
|
||||||
<xsl:attribute name="font-size" select="if (self::xr:SUB_INVOICE_LINE) then '90%' else '100%'"/>
|
<xsl:attribute name="font-size" select="if (self::xr:SUB_INVOICE_LINE) then '90%' else '100%'"/>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="invoicelines-nested-info">
|
<xsl:attribute-set name="invoicelines-nested-info">
|
||||||
<xsl:attribute name="font-size">80%</xsl:attribute>
|
<xsl:attribute name="font-size">80%</xsl:attribute>
|
||||||
<xsl:attribute name="font-style">italic</xsl:attribute>
|
<xsl:attribute name="font-style">italic</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
<xsl:attribute-set name="invoicelines-allowances-table">
|
<xsl:attribute-set name="invoicelines-allowances-table">
|
||||||
<xsl:attribute name="padding-left">2pt</xsl:attribute>
|
<xsl:attribute name="padding-left">2pt</xsl:attribute>
|
||||||
<xsl:attribute name="padding-right">2pt</xsl:attribute>
|
<xsl:attribute name="padding-right">2pt</xsl:attribute>
|
||||||
<xsl:attribute name="width">100%</xsl:attribute>
|
<xsl:attribute name="width">100%</xsl:attribute>
|
||||||
<xsl:attribute name="table-layout">fixed</xsl:attribute>
|
<xsl:attribute name="table-layout">fixed</xsl:attribute>
|
||||||
<xsl:attribute name="font-size">80%</xsl:attribute>
|
<xsl:attribute name="font-size">80%</xsl:attribute>
|
||||||
<xsl:attribute name="font-style">italic</xsl:attribute>
|
<xsl:attribute name="font-style">italic</xsl:attribute>
|
||||||
</xsl:attribute-set>
|
</xsl:attribute-set>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
|||||||
@@ -1,289 +1,313 @@
|
|||||||
/**
|
/**
|
||||||
* *********************************************************************
|
* *********************************************************************
|
||||||
* <p>
|
* <p>
|
||||||
* Copyright 2019 Jochen Staerk
|
* Copyright 2019 Jochen Staerk
|
||||||
* <p>
|
* <p>
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
* <p>
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
* <p>
|
* <p>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* <p>
|
* <p>
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* <p>
|
* <p>
|
||||||
* **********************************************************************
|
* **********************************************************************
|
||||||
*/
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.mustangproject.util.ByteArraySearcher;
|
import org.mustangproject.util.ByteArraySearcher;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class VisualizationTest extends ResourceCase {
|
public class VisualizationTest extends ResourceCase {
|
||||||
|
|
||||||
final String TARGET_PDF_CII = "./target/testout-Visualization-cii.pdf";
|
final String TARGET_PDF_CII = "./target/testout-Visualization-cii.pdf";
|
||||||
final String TARGET_PDF_UBL = "./target/testout-Visualization-cii.pdf";
|
final String TARGET_PDF_UBL = "./target/testout-Visualization-cii.pdf";
|
||||||
|
|
||||||
public void testCIIVisualizationBasic() {
|
public void testCIIVisualizationBasic() {
|
||||||
|
|
||||||
// the writing part
|
// the writing part
|
||||||
String sourceFilename = "factur-x.xml";
|
String sourceFilename = "factur-x.xml";
|
||||||
File CIIinputFile = getResourceAsFile(sourceFilename);
|
File CIIinputFile = getResourceAsFile(sourceFilename);
|
||||||
|
|
||||||
String expected = null;
|
String expected = null;
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
/* remove file endings so that tests can also pass after checking
|
/* remove file endings so that tests can also pass after checking
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
*/
|
*/
|
||||||
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.FR)
|
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.FR);
|
||||||
.replace("\r", "")
|
Files.write(Paths.get("./target/testout-factur-x-vis.fr.html"), result.getBytes(StandardCharsets.UTF_8));
|
||||||
.replace("\n", "")
|
result = result
|
||||||
.replace("\t", "")
|
.replace("\r", "")
|
||||||
.replace(" ", "");
|
.replace("\n", "")
|
||||||
|
.replace("\t", "")
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis.fr.html");
|
.replace(" ", "");
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
|
||||||
.replace("\r", "")
|
File expectedResult = getResourceAsFile("factur-x-vis.fr.html");
|
||||||
.replace("\n", "")
|
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
||||||
.replace("\t", "")
|
.replace("\r", "")
|
||||||
.replace(" ", "");
|
.replace("\n", "")
|
||||||
// remove linebreaks as well...
|
.replace("\t", "")
|
||||||
|
.replace(" ", "");
|
||||||
} catch (UnsupportedOperationException e) {
|
// remove linebreaks as well...
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
} catch (TransformerException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (TransformerException e) {
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
fail("TransformerException should not happen: " + e.getMessage());
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (IOException e) {
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
fail("IOException should not happen: " + e.getMessage());
|
||||||
} catch (SAXException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
||||||
}
|
} catch (SAXException e) {
|
||||||
|
fail("SAXException should not happen: " + e.getMessage());
|
||||||
|
}
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
assertEquals(expected, result);
|
assertNotNull(result);
|
||||||
}
|
// Reading ZUGFeRD
|
||||||
|
assertEquals(expected, result);
|
||||||
public void testCIIVisualizationExtended() {
|
}
|
||||||
|
|
||||||
// the writing part
|
public void testCIIVisualizationExtended() {
|
||||||
String sourceFilename = "factur-x-extended.xml";
|
|
||||||
File CIIinputFile = getResourceAsFile(sourceFilename);
|
// the writing part
|
||||||
|
String sourceFilename = "factur-x-extended.xml";
|
||||||
String expected = null;
|
File CIIinputFile = getResourceAsFile(sourceFilename);
|
||||||
String result = null;
|
|
||||||
try {
|
String expected = null;
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
String result = null;
|
||||||
/* remove file endings so that tests can also pass after checking
|
try {
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
*/
|
/* remove file endings so that tests can also pass after checking
|
||||||
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.DE).replace("\r", "").replace("\n", "")
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
.replace("\t", "")
|
*/
|
||||||
.replace(" ", "");
|
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.DE);
|
||||||
|
Files.write(Paths.get("./target/testout-factur-x-vis-extended.de.html"), result.getBytes(StandardCharsets.UTF_8));
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-extended.de.html");
|
result = result
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "")
|
.replace("\r", "")
|
||||||
.replace("\t", "")
|
.replace("\n", "")
|
||||||
.replace(" ", "");
|
.replace("\t", "")
|
||||||
// remove linebreaks as well...
|
.replace(" ", "");
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
File expectedResult = getResourceAsFile("factur-x-vis-extended.de.html");
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
||||||
} catch (IllegalArgumentException e) {
|
.replace("\r", "")
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
.replace("\n", "")
|
||||||
} catch (TransformerException e) {
|
.replace("\t", "")
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
.replace(" ", "");
|
||||||
} catch (IOException e) {
|
// remove linebreaks as well...
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
} catch (SAXException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
}
|
} catch (TransformerException e) {
|
||||||
|
fail("TransformerException should not happen: " + e.getMessage());
|
||||||
|
} catch (IOException e) {
|
||||||
assertNotNull(result);
|
fail("IOException should not happen: " + e.getMessage());
|
||||||
// Reading ZUGFeRD
|
} catch (ParserConfigurationException e) {
|
||||||
assertEquals(expected, result);
|
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
||||||
}
|
} catch (SAXException e) {
|
||||||
|
fail("SAXException should not happen: " + e.getMessage());
|
||||||
public void testUBLCreditNoteVisualizationBasic() {
|
}
|
||||||
|
|
||||||
// the writing part
|
|
||||||
File UBLinputFile = getResourceAsFile("ubl-creditnote.xml");
|
assertNotNull(result);
|
||||||
|
// Reading ZUGFeRD
|
||||||
String expected = null;
|
assertEquals(expected, result);
|
||||||
String result = null;
|
}
|
||||||
try {
|
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
public void testUBLCreditNoteVisualizationBasic() {
|
||||||
/* remove file endings so that tests can also pass after checking
|
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
// the writing part
|
||||||
*/
|
File UBLinputFile = getResourceAsFile("ubl-creditnote.xml");
|
||||||
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN).replace("\r", "").replace("\n", "").replace("\t", "").replace(" ", "");
|
|
||||||
|
String expected = null;
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-ubl-creditnote.en.html");
|
String result = null;
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "").replace("\t", "").replace(" ", "");
|
try {
|
||||||
// remove linebreaks as well...
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
|
/* remove file endings so that tests can also pass after checking
|
||||||
} catch (UnsupportedOperationException e) {
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
*/
|
||||||
} catch (IllegalArgumentException e) {
|
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN);
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
Files.write(Paths.get("./target/testout-factur-x-vis-ubl-creditnote.en.html"), result.getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (TransformerException e) {
|
result = result
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
.replace("\r", "")
|
||||||
} catch (IOException e) {
|
.replace("\n", "")
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
.replace("\t", "")
|
||||||
} catch (ParserConfigurationException e) {
|
.replace(" ", "");
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
|
||||||
} catch (SAXException e) {
|
File expectedResult = getResourceAsFile("factur-x-vis-ubl-creditnote.en.html");
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
||||||
}
|
.replace("\r", "")
|
||||||
|
.replace("\n", "")
|
||||||
|
.replace("\t", "")
|
||||||
assertNotNull(result);
|
.replace(" ", "");
|
||||||
// Reading ZUGFeRD
|
// remove linebreaks as well...
|
||||||
assertEquals(expected, result);
|
|
||||||
}
|
} catch (UnsupportedOperationException e) {
|
||||||
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
public void testUBLVisualizationBasic() {
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
|
} catch (TransformerException e) {
|
||||||
// the writing part
|
fail("TransformerException should not happen: " + e.getMessage());
|
||||||
File UBLinputFile = getResourceAsFile("ubl/01.01a-INVOICE.ubl.xml");
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not happen: " + e.getMessage());
|
||||||
String expected = null;
|
} catch (ParserConfigurationException e) {
|
||||||
String result = null;
|
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
||||||
try {
|
} catch (SAXException e) {
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
fail("SAXException should not happen: " + e.getMessage());
|
||||||
/* remove file endings so that tests can also pass after checking
|
}
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN).replace("\r", "").replace("\n", "")
|
assertNotNull(result);
|
||||||
.replace("\t", "")
|
// Reading ZUGFeRD
|
||||||
.replace(" ", "");
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-ubl.en.html");
|
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
public void testUBLVisualizationBasic() {
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
// the writing part
|
||||||
|
File UBLinputFile = getResourceAsFile("ubl/01.01a-INVOICE.ubl.xml");
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
String expected = null;
|
||||||
} catch (IllegalArgumentException e) {
|
String result = null;
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
try {
|
||||||
} catch (TransformerException e) {
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
/* remove file endings so that tests can also pass after checking
|
||||||
} catch (IOException e) {
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
*/
|
||||||
} catch (ParserConfigurationException e) {
|
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN);
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
Files.write(Paths.get("./target/testout-factur-x-vis-ubl.en.html"), result.getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (SAXException e) {
|
result = result
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
.replace("\r", "")
|
||||||
}
|
.replace("\n", "")
|
||||||
|
.replace("\t", "")
|
||||||
|
.replace(" ", "");
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
File expectedResult = getResourceAsFile("factur-x-vis-ubl.en.html");
|
||||||
assertEquals(expected, result);
|
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
||||||
}
|
.replace("\r", "")
|
||||||
|
.replace("\n", "")
|
||||||
public void testPDFVisualizationCII() {
|
.replace("\t", "")
|
||||||
|
.replace(" ", "");
|
||||||
File CIIinputFile = getResourceAsFile("cii/01.01a-INVOICE.cii.xml");
|
// remove linebreaks as well...
|
||||||
|
|
||||||
// the writing part
|
} catch (UnsupportedOperationException e) {
|
||||||
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
String expected = null;
|
} catch (IllegalArgumentException e) {
|
||||||
String result = null;
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
try {
|
} catch (TransformerException e) {
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
fail("TransformerException should not happen: " + e.getMessage());
|
||||||
zvi.toPDF(CIIinputFile.getAbsolutePath(), TARGET_PDF_CII);
|
} catch (IOException e) {
|
||||||
} catch (UnsupportedOperationException e) {
|
fail("IOException should not happen: " + e.getMessage());
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
} catch (ParserConfigurationException e) {
|
||||||
} catch (IllegalArgumentException e) {
|
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
} catch (SAXException e) {
|
||||||
}
|
fail("SAXException should not happen: " + e.getMessage());
|
||||||
|
}
|
||||||
try {
|
|
||||||
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
|
||||||
} catch (IOException e) {
|
assertNotNull(result);
|
||||||
fail("IOException should not occur");
|
// Reading ZUGFeRD
|
||||||
}
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPDFVisualizationUBL() {
|
public void testPDFVisualizationCII() {
|
||||||
|
|
||||||
File UBLinputFile = getResourceAsFile("ubl/01.01a-INVOICE.ubl.xml");
|
File CIIinputFile = getResourceAsFile("cii/01.01a-INVOICE.cii.xml");
|
||||||
|
|
||||||
// the writing part
|
// the writing part
|
||||||
String sourceFilename = "factur-x.xml";
|
|
||||||
|
String expected = null;
|
||||||
String expected = null;
|
String result = null;
|
||||||
String result = null;
|
try {
|
||||||
try {
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
zvi.toPDF(CIIinputFile.getAbsolutePath(), TARGET_PDF_CII);
|
||||||
zvi.toPDF(UBLinputFile.getAbsolutePath(), TARGET_PDF_UBL);
|
} catch (UnsupportedOperationException e) {
|
||||||
} catch (UnsupportedOperationException e) {
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
} catch (IllegalArgumentException e) {
|
||||||
} catch (IllegalArgumentException e) {
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
||||||
try {
|
} catch (IOException e) {
|
||||||
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
fail("IOException should not occur");
|
||||||
} catch (IOException e) {
|
}
|
||||||
fail("IOException should not occur");
|
}
|
||||||
}
|
|
||||||
}
|
public void testPDFVisualizationUBL() {
|
||||||
|
|
||||||
public void testPDFVisualizationUBLCreditNote() {
|
File UBLinputFile = getResourceAsFile("ubl/01.01a-INVOICE.ubl.xml");
|
||||||
|
|
||||||
File UBLinputFile = getResourceAsFile("ubl/UBL-CreditNote-2.1-Example.ubl.xml");
|
// the writing part
|
||||||
|
String sourceFilename = "factur-x.xml";
|
||||||
// the writing part
|
|
||||||
String sourceFilename = "factur-x.xml";
|
String expected = null;
|
||||||
|
String result = null;
|
||||||
String expected = null;
|
try {
|
||||||
String result = null;
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
try {
|
zvi.toPDF(UBLinputFile.getAbsolutePath(), TARGET_PDF_UBL);
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
} catch (UnsupportedOperationException e) {
|
||||||
zvi.toPDF(UBLinputFile.getAbsolutePath(), TARGET_PDF_UBL);
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
} catch (IllegalArgumentException e) {
|
}
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
||||||
try {
|
} catch (IOException e) {
|
||||||
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
fail("IOException should not occur");
|
||||||
} catch (IOException e) {
|
}
|
||||||
fail("IOException should not occur");
|
}
|
||||||
}
|
|
||||||
}
|
public void testPDFVisualizationUBLCreditNote() {
|
||||||
|
|
||||||
}
|
File UBLinputFile = getResourceAsFile("ubl/UBL-CreditNote-2.1-Example.ubl.xml");
|
||||||
|
|
||||||
|
// the writing part
|
||||||
|
String sourceFilename = "factur-x.xml";
|
||||||
|
|
||||||
|
String expected = null;
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
|
zvi.toPDF(UBLinputFile.getAbsolutePath(), TARGET_PDF_UBL);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
assertTrue(ByteArraySearcher.startsWith(Files.readAllBytes(Paths.get(TARGET_PDF_CII)), new byte[]{'%', 'P', 'D', 'F'}));
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not occur");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user