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