allow Order-X XML to be added manually, have Order-X-Functionality in Commandline
This commit is contained in:
@@ -32,8 +32,11 @@ public class CustomXMLProvider implements IXMLProvider {
|
||||
|
||||
public void setXML(byte[] newData) {
|
||||
String zf = new String(newData, StandardCharsets.UTF_8);
|
||||
if (!zf.contains("CrossIndustry")) {
|
||||
throw new RuntimeException("ZUGFeRD XML does not contain (<rsm:)CrossIndustry and can thus not be valid");
|
||||
/**
|
||||
* rsm:CrossIndustry is ZF/FX/XR (CII 2016b) and rsm:SCRDMCCBDACIOMessageStructure is of course Order-X (CIO 2021)
|
||||
*/
|
||||
if ((!zf.contains("rsm:CrossIndustry")) && (!zf.contains("rsm:SCRDMCCBDACIOMessageStructure"))) {
|
||||
throw new RuntimeException("ZUGFeRD XML does not contain <rsm:CrossIndustry or <rsm:SCRDMCCBDACIOMessageStructure and can thus not be valid");
|
||||
}
|
||||
|
||||
zugferdData = newData;
|
||||
|
||||
@@ -38,6 +38,22 @@ public class OXExporterFromA1 extends OXExporterFromA3 implements IZUGFeRDExport
|
||||
private static boolean isValidA1(DataSource dataSource) throws IOException {
|
||||
return getPDFAParserValidationResult(new PreflightParser(dataSource));
|
||||
}
|
||||
/***
|
||||
* internal helper function: get namespace for order-x
|
||||
* @param ver the order-x version
|
||||
* @return the URN of the namespace
|
||||
*/
|
||||
public String getNamespaceForVersion(int ver) {
|
||||
return "urn:factur-x:pdfa:CrossIndustryDocument:1p0#";
|
||||
}
|
||||
/***
|
||||
* internal helper: returns the namespace prefix for the given order-x version number
|
||||
* @param ver the ox version
|
||||
* @return the namespace prefix as string, without colon
|
||||
*/
|
||||
public String getPrefixForVersion(int ver) {
|
||||
return "fx";
|
||||
}
|
||||
|
||||
private static boolean getPDFAParserValidationResult(PreflightParser parser) throws IOException {
|
||||
/*
|
||||
|
||||
@@ -393,13 +393,15 @@ public class OXExporterFromA3 extends ZUGFeRDExporterFromA3 {
|
||||
XMPSchemaZugferd zf = new XMPSchemaZugferd(metadata, 1, true, xmlProvider.getProfile(),
|
||||
"urn:factur-x:pdfa:CrossIndustryDocument:1p0#", "fx",
|
||||
"order-x.xml");
|
||||
zf.setType("ORDER");
|
||||
|
||||
metadata.addSchema(zf);
|
||||
// also add the schema extensions...
|
||||
XMPSchemaPDFAExtensions pdfaex = new XMPSchemaPDFAExtensions(this, metadata, 1, attachZUGFeRDHeaders);
|
||||
pdfaex.setZUGFeRDVersion(1);
|
||||
metadata.addSchema(pdfaex);
|
||||
}
|
||||
|
||||
XMPSchemaPDFAExtensions pdfaex = new XMPSchemaPDFAExtensions(this, metadata, 1, attachZUGFeRDHeaders);
|
||||
pdfaex.setZUGFeRDVersion(1);
|
||||
metadata.addSchema(pdfaex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class XMPSchemaPDFAExtensions extends PDFAExtensionSchema {
|
||||
addProperty(newBag);
|
||||
if (withZF) {
|
||||
TextType pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.SCHEMA,
|
||||
"ZUGFeRD PDFA Extension Schema");
|
||||
"Factur-X PDFA Extension Schema");
|
||||
li.addProperty(pdfa1);
|
||||
|
||||
pdfa1 = new TextType(metadata, xmlns_pdfaSchema, prefix_pdfaSchema, PDFASchemaType.NAMESPACE_URI,
|
||||
|
||||
@@ -56,4 +56,13 @@ public class XMPSchemaZugferd extends XMPSchema {
|
||||
}
|
||||
setTextPropertyValue("Version", version);
|
||||
}
|
||||
|
||||
/***
|
||||
* Specify a custom XMP metadata document type
|
||||
* @param type INVOICE or ORDER
|
||||
*/
|
||||
public XMPSchemaZugferd setType(String type) {
|
||||
setTextPropertyValue("DocumentType", type);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,6 @@ public class ZUGFeRDExporterFromA3 extends XRExporter implements IZUGFeRDExporte
|
||||
return "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#";
|
||||
} else if (ver == 2) {
|
||||
return "urn:zugferd:pdfa:CrossIndustryDocument:invoice:2p0#";
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("Version not supported");
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
||||
" <pdfaExtension:schemas>\n" +
|
||||
" <rdf:Bag>\n" +
|
||||
" <rdf:li rdf:parseType=\"Resource\">\n" +
|
||||
" <pdfaSchema:schema>ZUGFeRD PDFA Extension Schema</pdfaSchema:schema>\n" +
|
||||
" <pdfaSchema:schema>Factur-X PDFA Extension Schema</pdfaSchema:schema>\n" +
|
||||
" <pdfaSchema:namespaceURI>urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>\n" +
|
||||
" <pdfaSchema:prefix>zf</pdfaSchema:prefix>\n" +
|
||||
" <pdfaSchema:property>\n" +
|
||||
|
||||
Reference in New Issue
Block a user