diff --git a/Mustang-CLI/pom.xml b/Mustang-CLI/pom.xml index 4d60dc86..3da16639 100644 --- a/Mustang-CLI/pom.xml +++ b/Mustang-CLI/pom.xml @@ -10,7 +10,7 @@ Mustang-CLI Mustang commandline tool jar - 1.9.0-alpha1 + 1.9.0-alpha1-SNAPSHOT @@ -31,7 +31,7 @@ org.mustangproject validator - 2.0.0-SNAPSHOT + 1.9.0-alpha1 diff --git a/library/pom.xml b/library/pom.xml index 0c082a08..0dab7a26 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.mustangproject library - 1.9.0-alpha1 + 1.9.0-alpha1-SNAPSHOT jar Library to write and read FacturX and ZUGFeRD e-invoices. The Mustang project is a java library to read and write ZUGFeRD meta data inside your invoice PDFs. To write files, a provided PDF/A will be combined with generated or provided XML. diff --git a/validator/pom.xml b/validator/pom.xml index 2746d7c1..b7fdca77 100644 --- a/validator/pom.xml +++ b/validator/pom.xml @@ -12,7 +12,7 @@ Library to validate Factur-X/ZUGFeRD 1.0 and 2.1 as well as XRechnung e-invoices. jar - 1.9.0-alpha1 + 1.9.0-alpha1-SNAPSHOT diff --git a/validator/src/main/java/org/mustangproject/validator/Validator.java b/validator/src/main/java/org/mustangproject/validator/Validator.java index bc776a4c..c1986a55 100644 --- a/validator/src/main/java/org/mustangproject/validator/Validator.java +++ b/validator/src/main/java/org/mustangproject/validator/Validator.java @@ -25,20 +25,37 @@ public abstract class Validator { } //abstract method - + + /*** + * prepare validation + * @param filename the filename of the xml file to be examined + * @throws IrrecoverableValidationError when any fatal errors arise, e.g. when the source file can not be found + */ public abstract void setFilename(String filename) throws IrrecoverableValidationError; + + /*** + * perform the validation + * @throws IrrecoverableValidationError any fatal errors, e.g. when the source file can not be found + */ public abstract void validate() throws IrrecoverableValidationError; + /** + * get validation result + * @return validation result as xml string + */ public String getXMLResult() { return context.getXMLResult(); } /*** * validates a schema, which can only be needed in XML validation - and in pdf validation for additional data - * @param xmlRawData - * @param schemaPath + * @param xmlRawData the XML to be validated + * @param schemaPath the filename of the schema file + * @param section the error message type code + * @param part whether the error message occurs in the pdf or xml part + * @throws IrrecoverableValidationError when any fatal errors arise, e.g. when the source file can not be found */ - protected void validateSchema(byte[] xmlRawData, String schemaPath,int section, EPart part) throws IrrecoverableValidationError { + protected void validateSchema(byte[] xmlRawData, String schemaPath, int section, EPart part) throws IrrecoverableValidationError { URL schemaFile = ClassLoader.getSystemResource("schema/" + schemaPath); Source xmlData = new StreamSource(new ByteArrayInputStream(xmlRawData)); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); diff --git a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java index c40c881b..8b804425 100644 --- a/validator/src/main/java/org/mustangproject/validator/XMLValidator.java +++ b/validator/src/main/java/org/mustangproject/validator/XMLValidator.java @@ -51,6 +51,11 @@ public class XMLValidator extends Validator { super(ctx); } + /*** + * set source file + * @param name + * @throws IrrecoverableValidationError + */ public void setFilename(String name) throws IrrecoverableValidationError { // from XML Filename filename = name; // file existence must have been checked before @@ -69,10 +74,20 @@ public class XMLValidator extends Validator { } } + /*** + * manually set the xml content + * @param xml the xml to be checked + */ public void setStringContent(String xml) { zfXML = xml; } + /** + * whether uri1 has the same meaning like uri1 (it has, if it only differs in the fragment, i.e. uri1#1==uri1#2 ) + * @param uri1 + * @param uri2 + * @return true if semantically identical + */ public static boolean matchesURI(String uri1, String uri2) { return (uri1.equals(uri2) || uri1.startsWith(uri2 + "#")); } @@ -85,13 +100,10 @@ public class XMLValidator extends Validator { disableNotices = true; } + /*** - * - * @param xmlString - * @param overrideProfileCheck - * if set to true, all ZF2 files will be checked against EN16931 - * schematron, since no other schematron is available - * @return + * perform validation + * @throws IrrecoverableValidationError if any fatal errors occur, e.g. source file can not be read */ @Override public void validate() throws IrrecoverableValidationError { @@ -315,6 +327,14 @@ public class XMLValidator extends Validator { } + /*** + * validate using a xslt file generated from a schematron in the build preparation of this software + * @param xml the xml to be checked + * @param xsltFilename the filename of the intermediate XSLT file + * @param section the error type code, if one arises + * @param severity how serious a error should be treated - may only be notice + * @throws IrrecoverableValidationError if anything happened that prevents further checks + */ public void validateSchematron(String xml, String xsltFilename, int section, ESeverity severity) throws IrrecoverableValidationError { ISchematronResource aResSCH = null; aResSCH = SchematronResourceXSLT.fromClassPath(xsltFilename);