closes #416
This commit is contained in:
@@ -15,7 +15,9 @@
|
|||||||
- Be able to validate XRechnung/UBL files #337
|
- Be able to validate XRechnung/UBL files #337
|
||||||
- ph-schematron aktualisiert, logback zugungsten log4j entfernt #402
|
- ph-schematron aktualisiert, logback zugungsten log4j entfernt #402
|
||||||
- java.util Logging zugungsten log4j entfernt #407
|
- java.util Logging zugungsten log4j entfernt #407
|
||||||
- ZF extended no longer requires deliveydate #409
|
- ZF extended no longer requires deliverydate #411
|
||||||
|
- Return all BankDetails from parsed CII xml. Closes #408.
|
||||||
|
- ubl visualization: do not require ubl namespace prefix #416
|
||||||
|
|
||||||
2.11.0
|
2.11.0
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -843,8 +843,9 @@ public class Main {
|
|||||||
} else {
|
} else {
|
||||||
zvi.toPDF(sourceName, outName);
|
zvi.toPDF(sourceName, outName);
|
||||||
}
|
}
|
||||||
} catch (TransformerException | IOException e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(e.getMessage(), e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
System.out.println("Written to " + outName);
|
System.out.println("Written to " + outName);
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ 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;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
import javax.xml.transform.Source;
|
import javax.xml.transform.Source;
|
||||||
import javax.xml.transform.Templates;
|
import javax.xml.transform.Templates;
|
||||||
@@ -63,6 +66,10 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.helger.commons.io.stream.StreamHelper;
|
import com.helger.commons.io.stream.StreamHelper;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class ZUGFeRDVisualizer {
|
public class ZUGFeRDVisualizer {
|
||||||
|
|
||||||
@@ -100,7 +107,7 @@ public class ZUGFeRDVisualizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String visualize(String xmlFilename, Language lang)
|
public String visualize(String xmlFilename, Language lang)
|
||||||
throws FileNotFoundException, TransformerException {
|
throws FileNotFoundException, TransformerException, IOException, SAXException, ParserConfigurationException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mXsltXRTemplate == null) {
|
if (mXsltXRTemplate == null) {
|
||||||
@@ -140,29 +147,34 @@ public class ZUGFeRDVisualizer {
|
|||||||
ByteArrayOutputStream iaos = new ByteArrayOutputStream();
|
ByteArrayOutputStream iaos = new ByteArrayOutputStream();
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
String zf1Signature = "rsm:CrossIndustryDocument";
|
String zf1Signature = "CrossIndustryDocument";
|
||||||
String zf2Signature = "rsm:CrossIndustryInvoice";
|
String zf2Signature = "CrossIndustryInvoice";
|
||||||
String ublSignature = "ubl:Invoice";
|
String ublSignature = "Invoice";
|
||||||
String ublCreditNoteSignature = "ubl:CreditNote";
|
String ublCreditNoteSignature = "CreditNote";
|
||||||
boolean doPostProcessing = false;
|
boolean doPostProcessing = false;
|
||||||
if (fileContent.contains(zf1Signature)) {
|
|
||||||
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
dbf.setNamespaceAware(true);
|
||||||
|
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
|
Document doc = db.parse(new InputSource(fis));
|
||||||
|
Element root = doc.getDocumentElement();
|
||||||
|
fis = new FileInputStream(xmlFilename); // fis wont reset() so re-read from beginning
|
||||||
|
if (root.getLocalName().equals(zf1Signature)) {
|
||||||
applyZF1XSLT(fis, baos);
|
applyZF1XSLT(fis, baos);
|
||||||
|
} else if (root.getLocalName().equals(zf2Signature)) {
|
||||||
} else if (fileContent.contains(zf2Signature)) {
|
|
||||||
|
|
||||||
//zf2 or fx
|
//zf2 or fx
|
||||||
applyZF2XSLT(fis, iaos);
|
applyZF2XSLT(fis, iaos);
|
||||||
doPostProcessing = true;
|
doPostProcessing = true;
|
||||||
} else if (fileContent.contains(ublSignature)) {
|
} else if (root.getLocalName().equals(ublSignature)) {
|
||||||
//zf2 or fx
|
//zf2 or fx
|
||||||
applyUBL2XSLT(fis, iaos);
|
applyUBL2XSLT(fis, iaos);
|
||||||
doPostProcessing = true;
|
doPostProcessing = true;
|
||||||
|
} else if (root.getLocalName().equals(ublCreditNoteSignature)) {
|
||||||
} else if (fileContent.contains(ublCreditNoteSignature)) {
|
|
||||||
//zf2 or fx
|
//zf2 or fx
|
||||||
applyUBLCreditNote2XSLT(fis, iaos);
|
applyUBLCreditNote2XSLT(fis, iaos);
|
||||||
doPostProcessing = true;
|
doPostProcessing = true;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("File does not look like CII or UBL");
|
||||||
}
|
}
|
||||||
if (doPostProcessing) {
|
if (doPostProcessing) {
|
||||||
// take the copy of the stream and re-write it to an InputStream
|
// take the copy of the stream and re-write it to an InputStream
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.*;
|
import javax.xml.transform.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -57,10 +59,13 @@ public class VisualizationTest extends ResourceCase {
|
|||||||
fail("TransformerException should not happen: "+e.getMessage());
|
fail("TransformerException should not happen: "+e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not happen: "+e.getMessage());
|
fail("IOException should not happen: "+e.getMessage());
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
fail("ParserConfigurationException should not happen: "+e.getMessage());
|
||||||
|
} catch (SAXException e) {
|
||||||
|
fail("SAXException should not happen: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
@@ -91,10 +96,13 @@ public class VisualizationTest extends ResourceCase {
|
|||||||
fail("TransformerException should not happen: "+e.getMessage());
|
fail("TransformerException should not happen: "+e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not happen: "+e.getMessage());
|
fail("IOException should not happen: "+e.getMessage());
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
fail("ParserConfigurationException should not happen: "+e.getMessage());
|
||||||
|
} catch (SAXException e) {
|
||||||
|
fail("SAXException should not happen: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
@@ -125,10 +133,13 @@ public class VisualizationTest extends ResourceCase {
|
|||||||
fail("TransformerException should not happen: "+e.getMessage());
|
fail("TransformerException should not happen: "+e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not happen: "+e.getMessage());
|
fail("IOException should not happen: "+e.getMessage());
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
fail("ParserConfigurationException should not happen: "+e.getMessage());
|
||||||
|
} catch (SAXException e) {
|
||||||
|
fail("SAXException should not happen: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
|
|||||||
Reference in New Issue
Block a user