ZF1 backward compatbility on export

This commit is contained in:
Jochen Stärk
2018-05-07 15:44:51 +02:00
parent ba3979e7f2
commit 06e68d09e7
2 changed files with 29 additions and 0 deletions

View File

@@ -301,6 +301,17 @@ public class ZUGFeRDExporter implements Closeable {
PDFAttachGenericFile(doc, filename, "Alternative",
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
"text/xml", xmlProvider.getXML());
if (ZFVersion>1) {
// Also attach a ZF1 file for backward compatibility
setZUGFeRDVersion(1);
xmlProvider.generateXML(trans);
filename = getFilenameForVersion(ZFVersion);
PDFAttachGenericFile(doc, filename, "Alternative",
"Invoice metadata conforming to ZUGFeRD standard (http://www.ferd-net.de/front_content.php?idcat=231&lang=4)",
"text/xml", xmlProvider.getXML());
}
}
public void export(String ZUGFeRDfilename) throws IOException {

View File

@@ -18,6 +18,10 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
@@ -174,6 +178,20 @@ public class ZUGFeRDImporter {
*
*/
/***
* we should switch to xpath like this
// Create XPathFactory object
XPathFactory xpathFactory = XPathFactory.newInstance();
// Create XPath object
XPath xpath = xpathFactory.newXPath();
XPathExpression expr =
xpath.compile("//*[local-name()=\"GuidelineSpecifiedDocumentContextParameter\"]/[local-name()=\"ID\"]");
//evaluate expression result on XML document
ndList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
*/
ndList = document.getElementsByTagNameNS("*", "PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {