The validator is an XML validation engine to validate and process XML files in various formats. It basically does the following in order:
- identify actual xml format
- validate the xml file (using schema and schematron rules)
- generate a custom report / extract custom data from the xml file
- compute an acceptance status (according the supplied schema and rules)
The validator depends on self definedscenarioswhich are used to fully configure the process. It always creates avalidation report in XML.The actual content of this is controlled by the scenario.
Seearchitecturefor information about the actual validation process.
The validator is just an engine and does not know anything about XML documents and has no own validation rules. Validation rules and details are defined invalidation scenarioswhich are used to fully configure the validation process. All configurations are self-contained modules which are deployed and developed on their own.
Currently, there are two public third party validation configurations available.
- Validation Configuration forXRechnung:
- Validation Configuration forXGewerbeanzeige
The validator can be used in three different ways:
- as standalone application running from the cli
- as library embedded within a custom application
- as a daemon providing a http interface
The general way using the CLI is:
java -jar validationtool-<version>-standalone.jar -s<scenario-config-file>[OPTIONS] [FILE] [FILE] [FILE]...
The help option displays further CLI options to customize the process:
java -jar validationtool-<version>-standalone.jar --help
A concrete example with a specific validator configuration can be found on GitHub
TheCLI documentationshows further configuration options.
The validator can also be used in own Java Applications via the API. An example use of the API as follows:
Pathscenarios=Paths.get("scenarios.xml");
Configurationconfig=Configuration.load(scenarios.toUri());
Inputdocument=InputFactory.read(testDocument);
Checkvalidator=newDefaultCheck(config);
ResultvalidationResult=validator.checkInput(document);
// examine the result here
TheAPI documentationshows further configuration options.
Note:With Java 11+, you need to include a dependency toorg.glassfish.jaxb:jaxb-runtime
in your project explicitly,
as that dependency is markedoptional
in this project and
will thus not be resolved transitively.
You can also start the validator as a HTTP-Server. Just start it inDaemon-Modewith the-D
option.
java -jar validationtool-<version>-standalone.jar -s<scenario-config-file>-D
Thedaemon documentationshows more usage details and further configuration options.
The validator distribution contains the following artifacts:
- validationtool-
<version>
.jar:Java library for embedded use within an application - validationtool-
<version
>-standalone.jar:Uber-JAR for standalone usage containing all dependencies in one jar file. This file comes with JAXBembeddedand can be used with Java 8 and Java >= 11) - validationtool-
<version
>-java8-standalone.jar:Uber-JAR for standalone usage with Java JDK 8 containing all dependencies in one jar file. This file filedoes notcontain JAXB and depends on the bundled version of the JDK. - libs/*: directory containing all (incl. optional) dependencies of the validator