diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java index 2ad16e83..9e7e0417 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDExporter.java @@ -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 { diff --git a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java index 8f8ce19c..54ae06c4 100644 --- a/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java +++ b/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDImporter.java @@ -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; @@ -173,6 +177,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++) {