also convert ubl
This commit is contained in:
@@ -52,6 +52,7 @@ public class ZUGFeRDVisualizer {
|
||||
// }
|
||||
private TransformerFactory mFactory = null;
|
||||
private Templates mXsltXRTemplate = null;
|
||||
private Templates mXsltUBLTemplate = null;
|
||||
private Templates mXsltHTMLTemplate = null;
|
||||
private Templates mXsltZF1HTMLTemplate = null;
|
||||
|
||||
@@ -97,12 +98,24 @@ public class ZUGFeRDVisualizer {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
String zf1Signature = "rsm:CrossIndustryDocument";
|
||||
String zf2Signature = "rsm:CrossIndustryInvoice";
|
||||
String ublSignature = "ubl:Invoice";
|
||||
boolean doPostProcessing=false;
|
||||
if (fileContent.contains(zf1Signature)) {
|
||||
applyZF1XSLT(fis, baos);
|
||||
|
||||
} else {
|
||||
} else if (fileContent.contains(zf2Signature)) {
|
||||
|
||||
//zf2 or fx
|
||||
applyZF2XSLT(fis, iaos);
|
||||
doPostProcessing=true;
|
||||
} else if (fileContent.contains(ublSignature)) {
|
||||
//zf2 or fx
|
||||
applyUBL2XSLT(fis, iaos);
|
||||
doPostProcessing=true;
|
||||
|
||||
}
|
||||
if (doPostProcessing) {
|
||||
// take the copy of the stream and re-write it to an InputStream
|
||||
PipedInputStream in = new PipedInputStream();
|
||||
PipedOutputStream out;
|
||||
@@ -137,6 +150,7 @@ public class ZUGFeRDVisualizer {
|
||||
} catch (IOException e1) {
|
||||
LOG.log(Level.SEVERE, null, e1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return baos.toString("UTF-8");
|
||||
@@ -149,6 +163,17 @@ public class ZUGFeRDVisualizer {
|
||||
transformer.transform(new StreamSource(xmlFile), new StreamResult(HTMLOutstream));
|
||||
}
|
||||
|
||||
public void applyUBL2XSLT(final InputStream xmlFile, final OutputStream HTMLOutstream)
|
||||
throws TransformerException {
|
||||
if (mXsltUBLTemplate==null) {
|
||||
mXsltUBLTemplate = mFactory.newTemplates(
|
||||
new StreamSource(CLASS_LOADER.getResourceAsStream(RESOURCE_PATH + "stylesheets/ubl-invoice-xr.xsl")));
|
||||
}
|
||||
Transformer transformer = mXsltUBLTemplate.newTransformer();
|
||||
|
||||
transformer.transform(new StreamSource(xmlFile), new StreamResult(HTMLOutstream));
|
||||
}
|
||||
|
||||
public void applyZF1XSLT(final InputStream xmlFile, final OutputStream HTMLOutstream)
|
||||
throws TransformerException {
|
||||
Transformer transformer = mXsltZF1HTMLTemplate.newTransformer();
|
||||
|
||||
Reference in New Issue
Block a user