-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml
deleted file mode 100644
index 3b2acd8..0000000
--- a/.idea/saveactions_settings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.mvn/createBuildImages.sh b/.mvn/createBuildImages.sh
index 1cd5ec7..e29998b 100644
--- a/.mvn/createBuildImages.sh
+++ b/.mvn/createBuildImages.sh
@@ -16,7 +16,7 @@
# limitations under the License.
#
-TAGS=("3-openjdk-16" "3-jdk-11" "3-jdk-11-openj9" "3-jdk-8" "3-jdk-8-openj9" "3-openjdk-15" "3-openjdk-17" "3-openjdk-18" "3-eclipse-temurin-19-alpine")
+TAGS=("3-jdk-8" "3-jdk-8-openj9" "3-eclipse-temurin-11-alpine" "3-jdk-11-openj9" "3-eclipse-temurin-17-alpine" "3-eclipse-temurin-21-alpine" "3-eclipse-temurin-24-alpine")
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
for i in "${TAGS[@]}"
diff --git a/.mvn/settings-maven-central.xml b/.mvn/settings-maven-central.xml
new file mode 100644
index 0000000..30b15c3
--- /dev/null
+++ b/.mvn/settings-maven-central.xml
@@ -0,0 +1,11 @@
+
+
+
+ central
+ ${MVN_CENTRAL_USER}
+ ${MAVEN_CENTRAL_TOKEN}
+
+
+
diff --git a/.mvn/settings.xml b/.mvn/settings.xml
index d1b2b61..0b53a90 100644
--- a/.mvn/settings.xml
+++ b/.mvn/settings.xml
@@ -1,36 +1,6 @@
-
-
-
-
+gitlab-maven
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index 16bf637..0000000
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,127 +0,0 @@
-cleanup.add_default_serial_version_id=false
-cleanup.add_generated_serial_version_id=true
-cleanup.add_missing_annotations=true
-cleanup.add_missing_deprecated_annotations=true
-cleanup.add_missing_methods=false
-cleanup.add_missing_nls_tags=false
-cleanup.add_missing_override_annotations=true
-cleanup.add_missing_override_annotations_interface_methods=true
-cleanup.add_serial_version_id=false
-cleanup.always_use_blocks=true
-cleanup.always_use_parentheses_in_expressions=false
-cleanup.always_use_this_for_non_static_field_access=true
-cleanup.always_use_this_for_non_static_method_access=false
-cleanup.convert_functional_interfaces=false
-cleanup.convert_to_enhanced_for_loop=true
-cleanup.correct_indentation=false
-cleanup.format_source_code=true
-cleanup.format_source_code_changes_only=false
-cleanup.insert_inferred_type_arguments=false
-cleanup.make_local_variable_final=true
-cleanup.make_parameters_final=true
-cleanup.make_private_fields_final=true
-cleanup.make_type_abstract_if_missing_method=false
-cleanup.make_variable_declarations_final=true
-cleanup.never_use_blocks=false
-cleanup.never_use_parentheses_in_expressions=true
-cleanup.organize_imports=true
-cleanup.qualify_static_field_accesses_with_declaring_class=false
-cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-cleanup.qualify_static_member_accesses_with_declaring_class=true
-cleanup.qualify_static_method_accesses_with_declaring_class=false
-cleanup.remove_private_constructors=true
-cleanup.remove_redundant_type_arguments=true
-cleanup.remove_trailing_whitespaces=true
-cleanup.remove_trailing_whitespaces_all=true
-cleanup.remove_trailing_whitespaces_ignore_empty=false
-cleanup.remove_unnecessary_casts=true
-cleanup.remove_unnecessary_nls_tags=true
-cleanup.remove_unused_imports=true
-cleanup.remove_unused_local_variables=false
-cleanup.remove_unused_private_fields=true
-cleanup.remove_unused_private_members=false
-cleanup.remove_unused_private_methods=true
-cleanup.remove_unused_private_types=true
-cleanup.sort_members=false
-cleanup.sort_members_all=false
-cleanup.use_anonymous_class_creation=false
-cleanup.use_blocks=true
-cleanup.use_blocks_only_for_return_and_throw=false
-cleanup.use_lambda=true
-cleanup.use_parentheses_in_expressions=true
-cleanup.use_this_for_non_static_field_access=true
-cleanup.use_this_for_non_static_field_access_only_if_necessary=false
-cleanup.use_this_for_non_static_method_access=true
-cleanup.use_this_for_non_static_method_access_only_if_necessary=true
-cleanup.use_type_arguments=false
-cleanup_profile=_initCleanUpProfile
-cleanup_settings_version=2
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_initFormatterProfile
-formatter_settings_version=12
-org.eclipse.jdt.ui.ignorelowercasenames=true
-org.eclipse.jdt.ui.importorder=java;javax;org;com;lombok;de;
-org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.ondemandthreshold=99
-org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=/**\r\n * The ${bare_field_name} of this {@link ${enclosing_type}}.\r\n * \r\n * @return the ${bare_field_name}\r\n *//**\r\n * Sets the ${bare_field_name} of this {@link ${enclosing_type}}.\r\n *\r\n * @param ${param} the new ${bare_field_name} to set\r\n *//**\r\n * Creates a new instance of {@link ${enclosing_type}}.\r\n * ${tags}\r\n *//**\r\n * ${todo} Describe this class\r\n *\r\n * @author ${user}\r\n * ${tags}\r\n *//**\r\n * ${todo} Describe this method\r\n * ${tags}\r\n *//**\r\n * ${todo} Describe why this method is overridden.\r\n *//**\r\n * ${tags}\r\n * ${see_to_target}\r\n */${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}\r\n\r\n\r\n\r\n// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();// ${todo} Auto-generated method stub\r\n${body_statement}${body_statement}\r\n// ${todo} Auto-generated constructor stubreturn ${field};${field} \= ${param};
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=true
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=true
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=true
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_functional_interfaces=false
-sp_cleanup.convert_to_enhanced_for_loop=true
-sp_cleanup.correct_indentation=false
-sp_cleanup.format_source_code=true
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.insert_inferred_type_arguments=false
-sp_cleanup.make_local_variable_final=true
-sp_cleanup.make_parameters_final=true
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=true
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=true
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_redundant_type_arguments=false
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=true
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=true
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_anonymous_class_creation=false
-sp_cleanup.use_blocks=true
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_lambda=false
-sp_cleanup.use_parentheses_in_expressions=true
-sp_cleanup.use_this_for_non_static_field_access=true
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
-sp_cleanup.use_this_for_non_static_method_access=true
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
-sp_cleanup.use_type_arguments=false
diff --git a/.settings/settings.xml b/.settings/settings.xml
deleted file mode 100644
index d1b2b61..0000000
--- a/.settings/settings.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
- gitlab-maven
-
-
-
- Job-Token
- ${env.CI_JOB_TOKEN}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd7b759..f3f2e86 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,16 +2,50 @@
All notable changes to this project will be documented in this file.
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-# 1.5.0 (to be released)
+## 1.5.2 - 2025-09-01
+
+### Fixed
+
+- (BUILD) [#148](https://projekte.kosit.org/kosit/validator/-/issues/148): Regression that due to renaming from `validationtool` to `validator` the distribution zip did not contain all jars anymore
+
+# 1.5.1 - 2025-09-01
+
+### Fixed
+
+- (CORE) [#130](https://projekte.kosit.org/kosit/validator/-/issues/130) Check result to stdout causes an exception. This also fixes [GitHub #131](https://github.com/itplr-kosit/validator/issues/131)
+- (CORE) [#131](https://projekte.kosit.org/kosit/validator/-/issues/131) `UnsupportedOperationException` because of read-only list. This also fixes [GitHub #136](https://github.com/itplr-kosit/validator/issues/136)
+- (CLI) [#104](https://projekte.kosit.org/kosit/validator/-/issues/104) made the usage of the `-r` parameter optional, if only one unnamed scenario is used
+- (CLI) [#145](https://projekte.kosit.org/kosit/validator/-/issues/145) If the CLI is invoked without any parameter, the usage is shown twice
+- (DOC) [#129](https://projekte.kosit.org/kosit/validator/-/issues/129) API documentation is outdated. This also fixes [GitHub #130](https://github.com/itplr-kosit/validator/issues/130)
+- (BUILD) [#62](https://projekte.kosit.org/kosit/validator/-/issues/62) Surefire Test Error running `de.kosit.validationtool.impl.xml.RemoteResolvingStrategyTest` fails without `http.proxy` setting
+- (BUILD) [#110](https://projekte.kosit.org/kosit/validator/-/issues/110) reactivated the GitLab CI environment
+
+### Added
+
+- (BUILD) [#140](https://projekte.kosit.org/kosit/validator/-/issues/140) prepare pom.xml to be able to release to Maven Central
+- (BUILD) [#144](https://projekte.kosit.org/kosit/validator/-/issues/144) created a Maven profile to release on Maven Central
+
+### Changed
+
+- (CORE) [#109](https://projekte.kosit.org/kosit/validator/-/issues/109) dependencies were updated to the latest Java 1.8 compatible versions
+ - Bump [Saxon HE](https://www.saxonica.com/documentation11/documentation.xml) to 12.8
+ - Bump [jaxb-ri](https://github.com/eclipse-ee4j/jaxb-ri) to 2.3.9
+ - Bump [SLF4J](https://www.slf4j.org/) to 2.0.17
+- (CORE) [#136](https://projekte.kosit.org/kosit/validator/-/issues/136) removed IDE project folders from git
+- (BUILD) [#135](https://projekte.kosit.org/kosit/validator/-/issues/135) protected specific git branches
+- (BUILD) [#137](https://projekte.kosit.org/kosit/validator/-/issues/137) GitLab CI should only run on Java LTS versions as well as the latest Java version
+- (BUILD) [#147](https://projekte.kosit.org/kosit/validator/-/issues/147) Change Maven coordinates from `de.kosit:validationtool` to `org.kosit:validator`
+
+## 1.5.0
### Fixed
- (CLI) [#93](https://projekte.kosit.org/kosit/validator/-/issues/93) Remove usage information, when validation failed
- (CLI) [#95](https://projekte.kosit.org/kosit/validator/-/issues/95) NPE when using empty repository definition (-r "")
-- (CORE) [#101](https://github.com/itplr-kosit/validator/issues/101) Role is null in FailedAssert
+- (CORE) [GitHub #101](https://github.com/itplr-kosit/validator/issues/101) Role is null in FailedAssert
### Added
@@ -19,15 +53,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (API) Possibility to use preconfigured Saxon `Processor` instance for validation
### Changed
-- (CORE) [#100](https://github.com/itplr-kosit/validator/issues/100) Make createReport optional
+
+- (CORE) [GitHub #100](https://github.com/itplr-kosit/validator/issues/100) Make createReport optional
- (DAEMON) UI rewrite based on [Docusaurs](https://docusaurus.io)
-- (
- API) [ResolvingConfigurationStrategy.java#getProcessor()](de/kosit/validationtool/api/ResolvingConfigurationStrategy)
- is removed.
+- (API) [ResolvingConfigurationStrategy.java#getProcessor()](de/kosit/validationtool/api/ResolvingConfigurationStrategy) is removed.
- (CORE) Bump [Saxon HE](https://www.saxonica.com/documentation11/documentation.xml) to 11.4
- (CORE) Bump [jaxb-ri](https://github.com/eclipse-ee4j/jaxb-ri) to 2.3.7
- (CORE) Various other dependency updates. See pom.xml
-
- (CORE) CLI parsing based on pico-cli, commons-cli is removed
## 1.4.2
@@ -38,14 +70,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#80](https://github.com/itplr-kosit/validator/issues/80) using classloader to initialize jaxb context (to support
usage in OSGi
environments)
-- [#75] (https://github.com/itplr-kosit/validator/issues/75) Improve logging on invalid documents
+- [#75] () Improve logging on invalid documents
## 1.4.1
### Fixed
- Allow more than 3 customLevel elements in scenarios (see xrechnung
- configuration [ issue 49](https://github.com/itplr-kosit/validator-configuration-xrechnung/issues/49))
+ configuration [issue 49](https://github.com/itplr-kosit/validator-configuration-xrechnung/issues/49))
- Remove saxon signature from java8 uber-jar (see [67](https://github.com/itplr-kosit/validator/issues/67))
## 1.4.0
@@ -135,13 +167,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
-- *Result#getAcceptRecommendation()* does not _only_ work when _acceptMatch_ is configured in the scenario
- - schema correctness is a precondition, if the checked instance is not valid, this evaluates to _REJECTED_
- - if _acceptMatch_ is configured, the result is based on the boolean result of the xpath expression evaluated against
+- *Result#getAcceptRecommendation()* does not *only* work when *acceptMatch* is configured in the scenario
+ - schema correctness is a precondition, if the checked instance is not valid, this evaluates to *REJECTED*
+ - if *acceptMatch* is configured, the result is based on the boolean result of the xpath expression evaluated against
the generated report
- - if *no* _acceptMatch_ is configured, the result is based on evaluation of schema and schematron correctness
- - _UNDEFINED_ is only returned, when processing is stopped somehow
-- *Result#isAcceptable()* can now evaluate to true, when no _acceptMatch_ is configured (see above)
+ - if *no* *acceptMatch* is configured, the result is based on evaluation of schema and schematron correctness
+ - *UNDEFINED* is only returned, when processing is stopped somehow
+- *Result#isAcceptable()* can now evaluate to true, when no *acceptMatch* is configured (see above)
## 1.1.3
@@ -172,10 +204,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-- Enhanced API-Usage e.g. return _Result_ object with processing information
+- Enhanced API-Usage e.g. return *Result* object with processing information
- Support loading scenarios and content from a JAR-File
- Simple Daemon-Mode exposing validation functionality via http
-- cli option to serialize the 'report input' xml document to _cwd_ (current working directory)
+- cli option to serialize the 'report input' xml document to *cwd* (current working directory)
- Documentation in `docs` folder
### Changed
diff --git a/NOTICE b/NOTICE
index 172c225..948af93 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
-KoSIT Validator
-Copyright 2017-2022 Koordinierungsstelle für IT-Standards (KoSIT)
+KoSIT XML Validator
+Copyright 2017-2025 Koordinierungsstelle für IT-Standards (KoSIT)
This product includes software developed by
-Koordinierungsstelle für IT-Standards (https://www.xoev.de/).
+Koordinierungsstelle für IT-Standards ().
diff --git a/README.md b/README.md
index 0fd508e..cf6d9f7 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# KoSIT Validator
+
- [Introduction](#introduction)
- [Validation Configurations](#validation-configurations)
* [Third Party Validation Configurations](#third-party-validation-configurations)
@@ -9,17 +10,18 @@
- [Packages](#packages)
## Introduction
-The validator is an XML validation engine to validate and process XML files in various formats. It basically does the following in order:
-1. identify actual xml format
-1. validate the xml file (using schema and schematron rules)
-1. generate a custom report / extract custom data from the xml file
+The validator is an XML validation engine to validate and process XML files in various formats. It basically does the following in order:
+
+1. identify actual XML format
+1. validate the XML file (using schema and schematron rules)
+1. generate a custom report / extract custom data from the XML file
1. compute an acceptance status (according the supplied schema and rules)
-The validator depends on self defined [scenarios](docs/configurations.md) which are used to fully configure the process.
-It always creates a [validation report in XML](docs/configurations.md#validators-report). The actual content of this is controlled by the scenario.
+The validator depends on self defined [scenarios](docs/configurations.md) in order to fully configure the whole process.
+It always creates a [validation report in XML](docs/configurations.md#validators-report). The actual content of the report can also be controlled by the scenario.
-See [architecture](docs/architecture.md) for information about the actual validation process.
+See [architecture](docs/architecture.md) for information about the whole validation process.
## Validation configurations
@@ -30,7 +32,7 @@ All configurations are self-contained modules which are deployed and developed o
### Third party validation configurations
-Currently, there are two public third party validation configurations available.
+Here are two public third party validation configurations available which might serve as examples:
* Validation Configuration for [XRechnung](http://www.xoev.de/de/xrechnung):
* Source code is available on [GitHub](https://github.com/itplr-kosit/validator-configuration-xrechnung)
@@ -43,28 +45,31 @@ Currently, there are two public third party validation configurations available.
The validator can be used in three different ways:
-* as standalone application running from the cli
+* as standalone application running from the CLI
* as library embedded within a custom application
* as a daemon providing a http interface
-### Standalone Command-Line Interface
+### Standalone Command Line Interface (CLI)
+
+**Important hint**: since v1.5.1 the filename has been changed from `validationtool-*` to `validator-*`
The general way using the CLI is:
```shell
-java -jar validationtool--standalone.jar -s [OPTIONS] [FILE] [FILE] [FILE] ...
+java -jar validator--standalone.jar -s -r
+[OPTIONS] [FILE] [FILE] [FILE] ...
```
The help option displays further CLI options to customize the process:
```shell
-java -jar validationtool--standalone.jar --help
+java -jar validator--standalone.jar --help
```
A concrete example with a specific validator configuration can be found on
[GitHub](https://github.com/itplr-kosit/validator-configuration-xrechnung)
-The [CLI documentation](./docs/cli.md) shows further configuration options.
+The [CLI documentation](./docs/cli.md) shows further configuration options.
### Application User Interface (API / embedded usage)
@@ -92,7 +97,7 @@ will thus not be resolved transitively.
You can also start the validator as a HTTP-Server. Just start it in _Daemon-Mode_ with the `-D` option.
```shell
-java -jar validationtool--standalone.jar -s -D
+java -jar validator--standalone.jar -s -D
```
@@ -102,7 +107,7 @@ The [daemon documentation](./docs/daemon.md) shows more usage details and furthe
The validator distribution contains the following artifacts:
-1. **validationtool-``.jar**: Java library for embedded use within an application
-1. **validationtool-`-standalone.jar**: Uber-JAR for standalone usage containing all dependencies in one jar file. This file comes with JAXB *embedded* and can be used with Java 8 and Java >= 11)
-1. **validationtool-`-java8-standalone.jar**: Uber-JAR for standalone usage with Java JDK 8 containing all dependencies in one jar file. This file file *does not* contain JAXB and depends on the bundled version of the JDK.
+1. **validator-``.jar**: Java library for embedded use within an application
+1. **validator-`-standalone.jar**: Uber-JAR for standalone usage containing all dependencies in one jar file. This file comes with JAXB *embedded* and can be used with Java 8 and Java >= 11)
+1. **validator-`-java8-standalone.jar**: Uber-JAR for standalone usage with Java JDK 8 containing all dependencies in one jar file. This file file *does not* contain JAXB and depends on the bundled version of the JDK.
1. **libs/***: directory containing all (incl. optional) dependencies of the validator
diff --git a/docs/api.md b/docs/api.md
index b26d428..caa93fe 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -12,8 +12,8 @@ Then you can declare the dependency as follows:
```xml
- de.kosit
- validationtool
+ org.kosit
+ validator${validator.version}
```
@@ -22,10 +22,12 @@ Then you can declare the dependency as follows:
```js
dependencies {
- compile group: 'de.kosit', name: 'validationtool', version: '1.1.0'
+ compile group: 'org.kosit', name: 'validator', version: '1.5.1'
}
```
+Hint: prior to v1.5.1 the group ID was `de.kosit` and the artifact ID was `validationtool`.
+
## Usage
Prerequisite for use is a valid [scenario definition](configurations.md) and the a folder with all necessary artifacts for validation (repository) either on the filesystem or on the classpath.
@@ -33,34 +35,39 @@ Prerequisite for use is a valid [scenario definition](configurations.md) and the
The following example demonstrates loading scenario.xml and whole configuration from classpath and validating one XML document:
```java
-package org.kosit.validator.example;
+package de.kosit.validationtool.docs;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
+import org.w3c.dom.Document;
+
import de.kosit.validationtool.api.Check;
import de.kosit.validationtool.api.Configuration;
import de.kosit.validationtool.api.Input;
import de.kosit.validationtool.api.InputFactory;
import de.kosit.validationtool.api.Result;
import de.kosit.validationtool.impl.DefaultCheck;
-import org.w3c.dom.Document;
+import de.kosit.validationtool.impl.xml.ProcessorProvider;
+/**
+ * Example code that is used in the docs/api.md file
+ */
public class StandardExample {
- public void run(Path testDocument) throws URISyntaxException {
+ public void run(final Path testDocument) throws URISyntaxException {
// Load scenarios.xml from classpath
- URL scenarios = this.getClass().getClassLoader().getResource("scenarios.xml");
+ final URL scenarios = this.getClass().getClassLoader().getResource("examples/simple/scenarios-with-relative-paths.xml");
// Load the rest of the specific Validator configuration from classpath
- Configuration config = Configuration.load(scenarios.toURI()).build();
+ final Configuration config = Configuration.load(scenarios.toURI()).build(ProcessorProvider.getProcessor());
// Use the default validation procedure
- Check validator = new DefaultCheck(config);
+ final Check validator = new DefaultCheck(config);
// Validate a single document
- Input document = InputFactory.read(testDocument);
+ final Input document = InputFactory.read(testDocument);
// Get Result including information about the whole validation
- Result report = validator.checkInput(document);
+ final Result report = validator.checkInput(document);
System.out.println("Is processing succesful=" + report.isProcessingSuccessful());
// Get report document if processing was successful
Document result = null;
@@ -70,13 +77,16 @@ public class StandardExample {
// continue processing results...
}
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
+ // Use e.g. "src/test/resources/examples/simple/input/foo.xml"
+ if (args.length == 0) {
+ throw new IllegalStateException("Provide a test document filename on the commandline");
+ }
// Path of document for validation
- Path testDoc = Paths.get(args[0]);
- StandardExample example = new StandardExample();
+ final Path testDoc = Paths.get(args[0]);
+ final StandardExample example = new StandardExample();
// run example validation
example.run(testDoc);
-
}
}
```
@@ -134,26 +144,36 @@ Instead of pre-configured [scenario files](configurations.md) it is possible to
A simple configuration looks like this:
```java
-import static de.kosit.validationtool.config.ConfigurationBuilder.*;
-import de.kosit.validationtool.api.Configuration;
-import java.net.URI;
-import java.nio.file.Path;
+package de.kosit.validationtool.docs;
+import static de.kosit.validationtool.config.ConfigurationBuilder.fallback;
+import static de.kosit.validationtool.config.ConfigurationBuilder.report;
+import static de.kosit.validationtool.config.ConfigurationBuilder.scenario;
+import static de.kosit.validationtool.config.ConfigurationBuilder.schema;
+import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
+
+import java.net.URI;
+import java.nio.file.Paths;
+
+import de.kosit.validationtool.api.Check;
+import de.kosit.validationtool.api.Configuration;
+import de.kosit.validationtool.impl.DefaultCheck;
+import de.kosit.validationtool.impl.xml.ProcessorProvider;
+
+/**
+ * Example code that is used in the docs/api.md file
+ */
public class MyValidator {
- public static void main(String[] args) {
- Configuration config = Configuration.create().name("myconfiguration")
- .with(scenario("firstScenario")
- .match("//myNode")
- .validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
- .validate(schematron("my rules").source("myRules.xsl"))
- .with(report("my report").source("report.xsl")))
- .with(fallback().name("default-report").source("fallback.xsl"))
- .useRepository(Paths.get("/opt/myrepository"))
- .build();
- Check validator = new DefaultCheck(config);
- // .. run your checks
- }
+ public static void main(final String[] args) {
+ final Configuration config = Configuration.create().name("myconfiguration")
+ .with(scenario("firstScenario").match("//myNode").validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
+ .validate(schematron("my rules").source("myRules.xsl")).with(report("my report").source("report.xsl")))
+ .with(fallback().name("default-report").source("fallback.xsl")).useRepository(Paths.get("/opt/myrepository"))
+ .build(ProcessorProvider.getProcessor());
+ final Check validator = new DefaultCheck(config);
+ // .. run your checks
+ }
}
```
@@ -188,19 +208,17 @@ which further opens the second to load resources also from remote locations via
You can configure usage of one of these implementations using the `ResolvingMode` via
-````java
-Conifuguration config = Configuration.load(URI.create("myscenarios.xml"))
- .resolvingMode(ResolvingMode.STRICT_LOCAL)
- .build();
-````
+```java
+final Configuration config = Configuration.load(URI.create("myscenarios.xml")).setResolvingMode(ResolvingMode.STRICT_LOCAL)
+ .build(ProcessorProvider.getProcessor());
+```
If you decide to implement your own strategy, you can configure this via:
-````java
-Conifuguration config = Configuration.load(URI.create("myscenarios.xml"))
- .resolvingStrategy(new MyCustomResolvingConfigurationStrategy())
- .build();
-````
+```java
+final Configuration config = Configuration.load(URI.create("myscenarios.xml"))
+ .setResolvingStrategy(new MyCustomResolvingConfigurationStrategy()).build(ProcessorProvider.getProcessor());
+```
---
diff --git a/docs/cli.md b/docs/cli.md
index 071f6da..492bedc 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -1,27 +1,29 @@
-# Validator CLI
+# Validator Command Line Interface (CLI)
-The validator comes with a commandline interface (CLI) which allows validating any number of input xml files.
+The `validator` comes with a command line interface (CLI) which allows validating any number of input XML files.
+
+**Important hint**: since v1.5.1 the filename has been changed from `validationtool-*` to `validator-*`
The general way using the CLI is:
```shell
-java -jar validationtool--standalone.jar -s [OPTIONS] [FILE] [FILE] [FILE] ...
+java -jar validator--standalone.jar -s [OPTIONS] [FILE] [FILE] [FILE] ...
```
-The validator can also read the xml file from the standard input
-
-```shell script
-# via redirection
-java -jar validationtool--standalone.jar -s [OPTIONS] < my-input.xml
-
-# read from pipe
-cat my-input.xml | validationtool--standalone.jar -s [OPTIONS]
-```
-
-The help option displays further CLI options to customize the process:
+The validator can also read the XML file from the standard input
```shell
-java -jar validationtool--standalone.jar --help
+# via redirection
+java -jar validator--standalone.jar -s [OPTIONS] < my-input.xml
+
+# read from pipe
+cat my-input.xml | validator--standalone.jar -s [OPTIONS]
+```
+
+The help option displays further CLI options:
+
+```shell
+java -jar validator--standalone.jar --help
```
You can also use multiple scenario configurations and multiple repositories with resources for these. The validator either supports
@@ -29,17 +31,17 @@ supplying the parameters in order or using named configuration. Valid usages are
```shell
# multiple scenarios, implicit repository
-java -jar validationtool--standalone.jar -s -s [OPTIONS] [FILE]
+java -jar validator--standalone.jar -s -s [OPTIONS] [FILE]
# multiple scenarios, single defined repository
-java -jar validationtool--standalone.jar -s -s -r [OPTIONS] [FILE]
+java -jar validator--standalone.jar -s -s -r [OPTIONS] [FILE]
# multiple scenarios, multiple repositories ordered
-java -jar validationtool--standalone.jar -s -r -s -r [OPTIONS] [FILE]
-java -jar validationtool--standalone.jar -s -s -r -r [OPTIONS] [FILE]
+java -jar validator--standalone.jar -s -r -s -r [OPTIONS] [FILE]
+java -jar validator--standalone.jar -s -s -r -r [OPTIONS] [FILE]
# multiple scenarios, multiple repositories (named)
-java -jar validationtool--standalone.jar -s "NAME1=" -s "NAME2=" -r "NAME1=" -r "NAME2=" [OPTIONS] [FILE]
+java -jar validator--standalone.jar -s "NAME1=" -s "NAME2=" -r "NAME1=" -r "NAME2=" [OPTIONS] [FILE]
```
## Special features
@@ -57,7 +59,7 @@ generated reports. This is mainly useful for scenario developers. Ask KoSIT for
| code | description |
|-|-|
-| 0 | All validated xml files are acceptable according to the scenario configurations |
+| 0 | All validated xml files are acceptable according to the scenario configurations or application usage was requested |
| positive integer | Number of rejected (e.g. not acceptable) xml files according to the scenario configurations|
| -1 | Parsing error. The commandline arguments specified are incorrect |
-| -2 | Configuration error. There is an error loading the configuration and/or validation targets |
+| -2 | Configuration error. There is an error loading the configuration and/or validation targets |
diff --git a/docs/daemon.md b/docs/daemon.md
index 04f3b92..a0f8f66 100644
--- a/docs/daemon.md
+++ b/docs/daemon.md
@@ -8,8 +8,10 @@ and should work with OpenJDK based distributions. Keep this in mind, if you want
To use the validator daemon as is, start the _Daemon-Mode_ with the `-D` option and supply a suitable
[validator configuration](configurations.md).
+**Important hint**: since v1.5.1 the filename has been changed from `validationtool-*` to `validator-*`
+
```shell
-java -jar validationtool--standalone.jar -s -D
+java -jar validator--standalone.jar -s -D
```
Per default the HTTP-Server listens on _localhost_ at Port 8080.
@@ -17,7 +19,7 @@ Per default the HTTP-Server listens on _localhost_ at Port 8080.
You can configure the daemon with `-H` for IP Adress and `-P` for port number:
```shell
-java -jar validationtool--standalone.jar -s -D -H 192.168.1.x -P 8081
+java -jar validator--standalone.jar -s -D -H 192.168.1.x -P 8081
```
## Customized usage
@@ -135,5 +137,5 @@ The daemon provides a simple GUI when issuing `GET` requests providing the follo
The GUI can be disabled using the API (see above) or via CLI:
```shell script
-java -jar validationtool--standalone.jar -s -D --disable-gui
+java -jar validator--standalone.jar -s -D --disable-gui
```
diff --git a/pom.xml b/pom.xml
index cd1efac..e6fbcff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,29 +1,13 @@
-
-
-
+4.0.0
- KoSIT XML Prüftool Implementierung
+ KoSIT XML Validator
- de.kosit
- 1.5.0
+ org.kosit
+ validator
+ 1.5.3-SNAPSHOT
- validationtoolKoSIT XML Validator against XSD and Schematron based on defined scenarios.
@@ -37,7 +21,7 @@
renzo.kottmannRenzo KottmannKoSIT
- http://www.xoev.de
+ http://www.xeinkauf.deProduct Owner
@@ -54,24 +38,37 @@
UTF-8
- 3.23.1
- 2.11.0
- 3.12.0
- 0.8.8
- 2.3.7
- 1.18.24
- 4.9.0
- 7.2.0
- 5.2.0
- 11.4
- 1.7.36
+ 3.27.3
+ 2.20.0
+ 3.18.0
+ 0.8.13
+ 2.3.9
+ 1.18.38
+ 4.11.0
+ 10.0.4
+ 5.5.5
+ 12.8
+ 2.0.17
+
project.localprojectfile:${project.basedir}/libs
+
+
+ Central Portal Snapshots
+ central-portal-snapshots
+ https://central.sonatype.com/repository/maven-snapshots/
+
+ false
+
+
+ true
+
+
@@ -95,13 +92,13 @@
info.picoclipicocli
- 4.7.0
+ 4.7.7trueorg.fusesource.jansijansi
- 2.4.0
+ 2.4.2true
@@ -131,7 +128,7 @@
junitjunit
- 4.13.1
+ 4.13.2test
@@ -142,7 +139,7 @@
io.rest-assuredrest-assured
- 5.3.0
+ ${version.rest-assured}test
@@ -172,11 +169,41 @@
+
+
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ 0.8.0
+ true
+
+ central
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 3.2.8
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.3.1
+
+ ISO-8859-1
+
+
+
org.codehaus.mojobuild-helper-maven-plugin
- 3.3.0
+ 3.6.1reserve-network-port
@@ -196,7 +223,7 @@
org.apache.maven.pluginsmaven-enforcer-plugin
- 3.1.0
+ 3.6.1enforce-versions
@@ -216,7 +243,7 @@
org.apache.maven.pluginsmaven-compiler-plugin
- 3.10.1
+ 3.14.01.81.8
@@ -227,7 +254,7 @@
org.apache.maven.pluginsmaven-shade-plugin
- 3.4.1
+ 3.6.0jdk11+
@@ -300,7 +327,7 @@
org.apache.maven.pluginsmaven-assembly-plugin
- 3.4.2
+ 3.7.1full_dist
@@ -325,7 +352,7 @@
org.jvnet.jaxb2.maven2maven-jaxb2-plugin
- 0.15.1
+ 0.15.3
@@ -345,7 +372,7 @@
org.jvnet.jaxb2_commonsjaxb2-basics
- 0.11.1
+ 0.13.1
@@ -400,11 +427,11 @@
dump
-
- localhost
- ${jacoco.tcp.port}
- true
-
+
+ localhost
+ ${jacoco.tcp.port}
+ true
+ generateJacocoReport
@@ -418,17 +445,23 @@
org.apache.maven.pluginsmaven-surefire-plugin
- 3.0.0-M7
+ 3.5.3-Dfile.encoding=UTF-8 ${jacocoSurefire}
+
+
+ java.net.useSystemProxies
+ true
+
+ org.apache.maven.pluginsmaven-source-plugin
- 3.2.1
+ 3.3.1attach-sources
@@ -442,7 +475,7 @@
org.apache.maven.pluginsmaven-release-plugin
- 2.5.3
+ 3.1.1v@{project.version}
@@ -451,17 +484,17 @@
org.codehaus.mojoexec-maven-plugin
- 3.1.0
+ 3.5.0
-
+ run
- pre-integration-test
-
+ pre-integration-test
+ exec
-
+
-
+ javafalsetrue
@@ -509,7 +542,7 @@
org.apache.maven.pluginsmaven-failsafe-plugin
- 3.0.0-M7
+ 3.5.3test-it
@@ -518,8 +551,8 @@
verify
-
- -Dfile.encoding=UTF-8 -Ddaemon.port=${validator.server.port}
+
+ -Dfile.encoding=UTF-8 -Ddaemon.port=${validator.server.port}
@@ -528,7 +561,7 @@
org.apache.maven.pluginsmaven-javadoc-plugin
- 3.4.1
+ 3.11.28none
@@ -577,8 +610,8 @@
+ org.apache.maven.pluginsmaven-gpg-plugin
- 1.6sign-artifacts
@@ -589,6 +622,10 @@
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+
@@ -623,13 +660,15 @@
format
- false
+
+ false
+ net.revelc.code.formatterformatter-maven-plugin
- 2.12.2
+ 2.13.0maven-formatting
@@ -646,6 +685,17 @@
+
+ release-snapshot
+
+
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+
+
+
+
@@ -655,12 +705,14 @@
- https://github.com/itplr-kosit/validationtool.git
+ scm:git:https://github.com/itplr-kosit/validator.gitscm:git:https://projekte.kosit.org/kosit/validator.git
- v1.1.0
+ release/1.5.xhttps://github.com/itplr-kosit/validator
+
https://github.com/itplr-kosit/validator
+
Apache License, Version 2.0
@@ -668,12 +720,4 @@
repo
-
-
- sonatype-nexus-staging
- Nexus Release Repository
- https://oss.sonatype.org/service/local/staging/deploy/maven2
-
-
-
diff --git a/src/assembly/assembly-dist.xml b/src/assembly/assembly-dist.xml
index a4fd78f..597eec6 100644
--- a/src/assembly/assembly-dist.xml
+++ b/src/assembly/assembly-dist.xml
@@ -1,22 +1,5 @@
-
-
+ xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
fullzip
@@ -35,7 +18,7 @@
${project.build.directory}
- validationtool-*.jar
+ validator-*.jar
diff --git a/src/main/java/de/kosit/validationtool/cmd/CommandLineApplication.java b/src/main/java/de/kosit/validationtool/cmd/CommandLineApplication.java
index b2a4fcd..09e3757 100644
--- a/src/main/java/de/kosit/validationtool/cmd/CommandLineApplication.java
+++ b/src/main/java/de/kosit/validationtool/cmd/CommandLineApplication.java
@@ -25,7 +25,6 @@ import org.fusesource.jansi.AnsiRenderer.Code;
import de.kosit.validationtool.cmd.report.Line;
import de.kosit.validationtool.impl.Printer;
-
import picocli.CommandLine;
import picocli.CommandLine.ParseResult;
@@ -79,11 +78,11 @@ public class CommandLineApplication {
final CommandLine commandLine = new CommandLine(new CommandLineOptions());
try {
commandLine.setExecutionExceptionHandler(CommandLineApplication::logExecutionException);
- commandLine.execute(args);
- if (commandLine.isUsageHelpRequested()) {
+ final int cmdlineRetVal = commandLine.execute(args);
+ if (commandLine.isUsageHelpRequested() || cmdlineRetVal == CommandLine.ExitCode.USAGE) {
resultStatus = ReturnValue.HELP_REQUEST;
} else {
- resultStatus = ObjectUtils.defaultIfNull(commandLine.getExecutionResult(), ReturnValue.PARSING_ERROR);
+ resultStatus = ObjectUtils.getIfNull(commandLine.getExecutionResult(), ReturnValue.PARSING_ERROR);
if (resultStatus.isError()) {
commandLine.usage(System.out);
}
diff --git a/src/main/java/de/kosit/validationtool/cmd/CommandLineOptions.java b/src/main/java/de/kosit/validationtool/cmd/CommandLineOptions.java
index 69e26d9..99cab94 100644
--- a/src/main/java/de/kosit/validationtool/cmd/CommandLineOptions.java
+++ b/src/main/java/de/kosit/validationtool/cmd/CommandLineOptions.java
@@ -20,12 +20,10 @@ import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.Callable;
+import de.kosit.validationtool.cmd.CommandLineApplication.Level;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-
-import de.kosit.validationtool.cmd.CommandLineApplication.Level;
-
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Help.Visibility;
@@ -38,10 +36,12 @@ import picocli.CommandLine.Parameters;
* @author Andreas Penski
*/
@Command(description = "Structural and semantic validation of xml files", name = "KoSIT Validator", mixinStandardHelpOptions = false,
- separator = " ")
+ separator = " ", synopsisHeading = CommandLineOptions.SYNOSIS_HEADING)
@Getter
public class CommandLineOptions implements Callable {
+ static final String SYNOSIS_HEADING = "Usage: ";
+
/**
* @author Andreas Penski
*/
@@ -175,9 +175,9 @@ public class CommandLineOptions implements Callable {
private static void configureLogging(final CommandLineOptions cmd) {
if (cmd.isDebugLog()) {
- System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
+ System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
} else {
- System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, cmd.getLogLevel().name());
+ System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, cmd.getLogLevel().name());
}
}
diff --git a/src/main/java/de/kosit/validationtool/cmd/Validator.java b/src/main/java/de/kosit/validationtool/cmd/Validator.java
index b5d37fc..a54e3b5 100644
--- a/src/main/java/de/kosit/validationtool/cmd/Validator.java
+++ b/src/main/java/de/kosit/validationtool/cmd/Validator.java
@@ -16,7 +16,7 @@
package de.kosit.validationtool.cmd;
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.ObjectUtils.getIfNull;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
@@ -37,14 +37,11 @@ import java.util.stream.Stream;
import org.fusesource.jansi.AnsiRenderer.Code;
-import lombok.extern.slf4j.Slf4j;
-
import de.kosit.validationtool.api.Configuration;
import de.kosit.validationtool.api.Input;
import de.kosit.validationtool.api.InputFactory;
import de.kosit.validationtool.api.Result;
import de.kosit.validationtool.cmd.CommandLineOptions.CliOptions;
-import de.kosit.validationtool.cmd.CommandLineOptions.Definition;
import de.kosit.validationtool.cmd.CommandLineOptions.RepositoryDefinition;
import de.kosit.validationtool.cmd.CommandLineOptions.ScenarioDefinition;
import de.kosit.validationtool.cmd.assertions.Assertions;
@@ -55,7 +52,7 @@ import de.kosit.validationtool.impl.EngineInformation;
import de.kosit.validationtool.impl.Printer;
import de.kosit.validationtool.impl.ScenarioRepository;
import de.kosit.validationtool.impl.xml.ProcessorProvider;
-
+import lombok.extern.slf4j.Slf4j;
import net.sf.saxon.s9api.Processor;
/**
@@ -132,7 +129,7 @@ public class Validator {
final Processor processor = ProcessorProvider.getProcessor();
final List config = getConfiguration(cmd);
final InternalCheck check = new InternalCheck(processor, config.toArray(new Configuration[0]));
- final CommandLineOptions.CliOptions cliOptions = defaultIfNull(cmd.getCliOptions(), new CliOptions());
+ final CommandLineOptions.CliOptions cliOptions = getIfNull(cmd.getCliOptions(), new CliOptions());
final Path outputDirectory = determineOutputDirectory(cliOptions);
if (cliOptions.isExtractHtml()) {
check.getCheckSteps().add(new ExtractHtmlContentAction(processor, outputDirectory));
@@ -180,17 +177,19 @@ public class Validator {
* @return a list of configurations of the scenarios and repositories passed in cmd
*/
private static List getConfiguration(final CommandLineOptions cmd) {
- final List scenarios = defaultIfNull(cmd.getScenarios(), Collections.emptyList());
+ final List scenarios = getIfNull(cmd.getScenarios(), Collections.emptyList());
+ // Map from scenario name to scenario path
final Map mappedScenarios = scenarios.stream()
.collect(Collectors.toMap(ScenarioDefinition::getName, ScenarioDefinition::getPath));
- final List repos = defaultIfNull(cmd.getRepositories(), Collections.emptyList());
- final Map mappedRepos = repos.stream().collect(Collectors.toMap(Definition::getName, Definition::getPath));
+ final List repos = getIfNull(cmd.getRepositories(), Collections.emptyList());
+ final Map mappedRepos = repos.stream()
+ .collect(Collectors.toMap(RepositoryDefinition::getName, RepositoryDefinition::getPath));
checkUnused(mappedScenarios, mappedRepos);
return mappedScenarios.entrySet().stream().map(e -> {
assertFileExistance(e.getValue(), "scenario");
final URI scenarioLocation = e.getValue().toUri();
- final URI repositoryLocation = findRepository(e.getKey(), mappedRepos);
+ final URI repositoryLocation = findRepository(scenarioLocation, e.getKey(), mappedRepos);
reportLoading(scenarioLocation, repositoryLocation);
final Configuration configuration = Configuration.load(scenarioLocation, repositoryLocation)
@@ -208,9 +207,14 @@ public class Validator {
unused.forEach(e -> Printer.writeErr("Warning: repository definition \"{0}\" is not used", e.getKey()));
}
- private static URI findRepository(final String key, final Map repositories) {
+ private static URI findRepository(final URI scenarioLocation, final String key, final Map repositories) {
final Path path = repositories.getOrDefault(key, repositories.get(ScenarioRepository.DEFAULT_ID));
if (path == null) {
+ // If it is an unnamed scenario, use the CWD instead
+ if (key.startsWith(ScenarioRepository.DEFAULT)) {
+ // Assume directory of scenario location instead
+ return Paths.get(scenarioLocation).getParent().toUri();
+ }
throw new IllegalArgumentException(String.format("No repository location for scenario definition '%s' specified", key));
}
return determineRepository(path);
diff --git a/src/main/java/de/kosit/validationtool/config/XPathBuilder.java b/src/main/java/de/kosit/validationtool/config/XPathBuilder.java
index 90b5351..713f951 100644
--- a/src/main/java/de/kosit/validationtool/config/XPathBuilder.java
+++ b/src/main/java/de/kosit/validationtool/config/XPathBuilder.java
@@ -114,7 +114,7 @@ class XPathBuilder implements Builder {
final Iterable iterable = () -> iterator;
StreamSupport.stream(iterable.spliterator(), false).filter(e -> !ArrayUtils.contains(IGNORED_PREFIXES, e))
.filter(StringUtils::isNotBlank).forEach(e -> ns.put(e, this.executable.getUnderlyingExpression().getInternalExpression()
- .getRetainedStaticContext().getURIForPrefix(e, false)));
+ .getRetainedStaticContext().getURIForPrefix(e, false).toString()));
getNamespaces().putAll(ns);
}
diff --git a/src/main/java/de/kosit/validationtool/impl/Printer.java b/src/main/java/de/kosit/validationtool/impl/Printer.java
index c165d97..cdfbbb4 100644
--- a/src/main/java/de/kosit/validationtool/impl/Printer.java
+++ b/src/main/java/de/kosit/validationtool/impl/Printer.java
@@ -38,7 +38,11 @@ public class Printer {
* @param params the params.
*/
public static void writeOut(final String message, final Object... params) {
- System.out.println(new MessageFormat(message, Locale.ENGLISH).format(params));
+ try {
+ System.out.println(new MessageFormat(message, Locale.ENGLISH).format(params));
+ } catch (final RuntimeException ex) {
+ System.err.println("[Format error!] <" + message + "> with params <" + params + ">");
+ }
}
/**
@@ -48,7 +52,11 @@ public class Printer {
* @param params the params.
*/
public static void writeErr(final String message, final Object... params) {
- System.err.println(new MessageFormat(message, Locale.ENGLISH).format(params));
+ try {
+ System.err.println(new MessageFormat(message, Locale.ENGLISH).format(params));
+ } catch (final RuntimeException ex) {
+ System.err.println("[Format error!] <" + message + "> with params <" + params + ">");
+ }
}
/**
diff --git a/src/main/java/de/kosit/validationtool/impl/Scenario.java b/src/main/java/de/kosit/validationtool/impl/Scenario.java
index 23deb7d..d92768a 100644
--- a/src/main/java/de/kosit/validationtool/impl/Scenario.java
+++ b/src/main/java/de/kosit/validationtool/impl/Scenario.java
@@ -16,22 +16,20 @@
package de.kosit.validationtool.impl;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.xml.transform.URIResolver;
import javax.xml.validation.Schema;
+import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
+import de.kosit.validationtool.model.scenarios.ResourceType;
+import de.kosit.validationtool.model.scenarios.ScenarioType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
-
-import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
-import de.kosit.validationtool.model.scenarios.ResourceType;
-import de.kosit.validationtool.model.scenarios.ScenarioType;
-
import net.sf.saxon.lib.UnparsedTextURIResolver;
import net.sf.saxon.s9api.XPathExecutable;
import net.sf.saxon.s9api.XPathSelector;
@@ -80,7 +78,11 @@ public class Scenario {
private Transformation reportTransformation;
public List getSchematronValidations() {
- return this.schematronValidations == null ? Collections.emptyList() : this.schematronValidations;
+ // Must return a mutable list
+ if (this.schematronValidations == null) {
+ this.schematronValidations = new ArrayList<>();
+ }
+ return this.schematronValidations;
}
public String getName() {
@@ -95,9 +97,9 @@ public class Scenario {
}
/**
- * Liefert einen neuen XPath-Selector zur Evaluierung der {@link de.kosit.validationtool.api.AcceptRecommendation}.
+ * Returns a new XPath selector for evaluating the {@link de.kosit.validationtool.api.AcceptRecommendation}.
*
- * @return neuer Selector
+ * @return new selector
*/
public Optional getAcceptSelector() {
final XPathSelector selector = this.acceptExecutable != null ? this.acceptExecutable.load() : null;
diff --git a/src/test/java/de/kosit/validationtool/cmd/CommandlineApplicationTest.java b/src/test/java/de/kosit/validationtool/cmd/CommandlineApplicationTest.java
index 4231b9f..f8ce55d 100644
--- a/src/test/java/de/kosit/validationtool/cmd/CommandlineApplicationTest.java
+++ b/src/test/java/de/kosit/validationtool/cmd/CommandlineApplicationTest.java
@@ -32,9 +32,8 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import lombok.extern.slf4j.Slf4j;
-
import de.kosit.validationtool.impl.Helper.Simple;
+import lombok.extern.slf4j.Slf4j;
/**
* Testet die Parameter des Kommandozeilen-Tools.
@@ -74,7 +73,7 @@ public class CommandlineApplicationTest {
@Test
public void testHelp() {
- final String[] args = new String[] { "-?" };
+ final String[] args = { "-?" };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isEmpty();
checkForHelp(CommandLine.getOutputLines());
@@ -82,12 +81,20 @@ public class CommandlineApplicationTest {
private static void checkForHelp(final List outputLines) {
assertThat(outputLines.size()).isPositive();
- assertThat(outputLines.stream().filter(l -> l.startsWith("Usage: KoSIT Validator"))).hasSize(1);
+ assertThat(outputLines.stream().filter(l -> l.startsWith(CommandLineOptions.SYNOSIS_HEADING))).hasSize(1);
+ }
+
+ @Test
+ public void testNoArguments() {
+ final String[] args = {};
+ CommandLineApplication.mainProgram(args);
+ assertThat(CommandLine.getErrorOutput()).isNotEmpty();
+ checkForHelp(CommandLine.getErrorLines());
}
@Test
public void testRequiredScenarioFile() {
- final String[] args = new String[] { "arguments", "egal welche", "argumente drin sind" };
+ final String[] args = { "arguments", "egal welche", "argumente drin sind" };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("Missing required option: '--scenarios");
@@ -95,7 +102,7 @@ public class CommandlineApplicationTest {
@Test
public void testNotExistingScenarioFile() {
- final String[] args = new String[] { "-s", Paths.get(Simple.NOT_EXISTING).toString(), Paths.get(Simple.NOT_EXISTING).toString() };
+ final String[] args = { "-s", Paths.get(Simple.NOT_EXISTING).toString(), Paths.get(Simple.NOT_EXISTING).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("Not a valid path for scenario definition specified");
@@ -103,7 +110,7 @@ public class CommandlineApplicationTest {
@Test
public void testIncorrectRepository() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.NOT_EXISTING).toString(),
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.NOT_EXISTING).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty();
@@ -112,8 +119,8 @@ public class CommandlineApplicationTest {
@Test
public void testNotExistingTestTarget() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.NOT_EXISTING).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.NOT_EXISTING).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("No test targets found");
@@ -121,17 +128,24 @@ public class CommandlineApplicationTest {
@Test
public void testValidMinimalConfiguration() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
+ CommandLineApplication.mainProgram(args);
+ assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
+ }
+
+ @Test
+ public void testValidMinimalConfigurationWithoutRepositoryPath() {
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS_WITH_RELATIVE_PATHS).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
}
@Test
public void testValidNamingConfiguration() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "somePrefix",
- "--report-postfix", "somePostfix" };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "somePrefix", "--report-postfix", "somePostfix" };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("somePrefix-simple-somePostfix");
@@ -139,7 +153,7 @@ public class CommandlineApplicationTest {
@Test
public void testValidMultipleInput() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), Paths.get(Simple.FOO).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Processing 2 object(s) completed");
@@ -147,7 +161,7 @@ public class CommandlineApplicationTest {
@Test
public void testValidDirectoryInput() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.EXAMPLES).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Processing 8 object(s) completed");
@@ -156,7 +170,7 @@ public class CommandlineApplicationTest {
@Test
public void testValidOutputConfiguration() throws IOException {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
@@ -167,8 +181,7 @@ public class CommandlineApplicationTest {
@Test
public void testNoInput() {
// assertThat(output).doesNotExist();
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), };
CommandLineApplication.mainProgram(args);
checkForHelp(CommandLine.getOutputLines());
}
@@ -176,8 +189,8 @@ public class CommandlineApplicationTest {
@Test
public void testPrint() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-o",
+ this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getOutputLines()).haveAtLeastOne(new Condition<>(
@@ -186,9 +199,8 @@ public class CommandlineApplicationTest {
@Test
public void testHtmlExtraktion() throws IOException {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-h", "-o",
- this.output.toAbsolutePath().toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
- Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-h", "-o", this.output.toAbsolutePath().toString(), "-r",
+ Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(Files.list(this.output).filter(f -> f.toString().endsWith(".html")).count()).isPositive();
@@ -196,9 +208,9 @@ public class CommandlineApplicationTest {
@Test
public void testAssertionsExtraktion() {
- final String[] args = new String[] { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), "-c", Paths.get(ASSERTIONS).toString(),
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-o",
+ this.output.toString(), "-c", Paths.get(ASSERTIONS).toString(), Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("Can not find assertions for ");
@@ -206,16 +218,16 @@ public class CommandlineApplicationTest {
@Test
public void testDebugFlag() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", "unknown", "-o", this.output.toString(),
- "-d", Paths.get(ASSERTIONS).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", "unknown", "-o", this.output.toString(), "-d",
+ Paths.get(ASSERTIONS).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("at de.kosit.validationtool");
}
@Test
public void testPrintMemoryStats() {
- final String[] args = new String[] { "-m", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-m", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("total");
@@ -223,32 +235,38 @@ public class CommandlineApplicationTest {
@Test
public void testReadFromPipe() throws IOException {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString() };
CommandLine.setStandardInput(Files.newInputStream(Paths.get(Simple.SIMPLE_VALID)));
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
}
+ @Test
+ public void testAndre() throws IOException {
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "andre1" };
+ CommandLineApplication.mainProgram(args);
+ assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
+ }
+
@Test
public void testUnexpectedDaemonFlag() {
- final String[] args = new String[] { "-D", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-D", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Will ignore cli mode options");
}
@Test
public void testParsingError() {
- final String[] args = new String[] { "-s", "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
- Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-s", "-r", Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Expected parameter for option");
}
@Test
public void loadMultipleScenarios() {
- final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
+ final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r",
"s2=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
@@ -257,7 +275,7 @@ public class CommandlineApplicationTest {
@Test
public void loadMultipleScenariosSingleRepository() {
- final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
+ final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
@@ -266,7 +284,7 @@ public class CommandlineApplicationTest {
@Test
public void loadMultipleScenariosMissingRepository() {
- final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
+ final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r",
"typo=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
@@ -275,16 +293,16 @@ public class CommandlineApplicationTest {
@Test
public void loadMultipleOrderedScenarios() {
- final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s",
- Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-r",
- Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
+ final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s", Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r",
+ Paths.get(Simple.REPOSITORY_URI).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
+ Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
}
@Test
public void checkUnusedRepository() {
- final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
+ final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
"s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
@@ -294,7 +312,7 @@ public class CommandlineApplicationTest {
@Test
public void checkDuplicationScenarioDefinition() {
- final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
+ final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
"s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
diff --git a/src/test/java/de/kosit/validationtool/config/ScenarioBuilderTest.java b/src/test/java/de/kosit/validationtool/config/ScenarioBuilderTest.java
index 42f2f58..f9f5590 100644
--- a/src/test/java/de/kosit/validationtool/config/ScenarioBuilderTest.java
+++ b/src/test/java/de/kosit/validationtool/config/ScenarioBuilderTest.java
@@ -34,7 +34,6 @@ import de.kosit.validationtool.impl.Scenario;
import de.kosit.validationtool.impl.model.Result;
import de.kosit.validationtool.model.scenarios.NamespaceType;
import de.kosit.validationtool.model.scenarios.ScenarioType;
-
import net.sf.saxon.s9api.XPathExecutable;
/**
@@ -140,6 +139,25 @@ public class ScenarioBuilderTest {
assertThat(configuration.getNamespace()).isEmpty();
}
+ @Test
+ public void testConfigureWithSchematron() {
+ final ContentRepository repository = Simple.createContentRepository();
+ final XPathExecutable match = repository.createXPath("//*", null);
+ final XPathExecutable accept = repository.createXPath("//*", null);
+ final ScenarioBuilder builder = createScenario();
+ builder.getNamespaces().clear();
+
+ builder.match(match);
+ builder.acceptWith(accept);
+ final Result result = builder.build(repository);
+ assertThat(result.isValid()).isTrue();
+ final ScenarioType configuration = result.getObject().getConfiguration();
+ assertThat(configuration.getMatch()).isNotEmpty();
+ assertThat(configuration.getAcceptMatch()).isNotEmpty();
+ assertThat(configuration.getNamespace()).isEmpty();
+ assertThat(configuration.getValidateWithSchematron()).isNotEmpty();
+ }
+
@Test
public void testBasicAttributes() {
final ContentRepository repository = Simple.createContentRepository();
diff --git a/src/test/java/de/kosit/validationtool/config/TestConfigurationFactory.java b/src/test/java/de/kosit/validationtool/config/TestConfigurationFactory.java
index 79ec407..0daacf7 100644
--- a/src/test/java/de/kosit/validationtool/config/TestConfigurationFactory.java
+++ b/src/test/java/de/kosit/validationtool/config/TestConfigurationFactory.java
@@ -20,6 +20,7 @@ import static de.kosit.validationtool.config.ConfigurationBuilder.fallback;
import static de.kosit.validationtool.config.ConfigurationBuilder.report;
import static de.kosit.validationtool.config.ConfigurationBuilder.scenario;
import static de.kosit.validationtool.config.ConfigurationBuilder.schema;
+import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
import java.net.URI;
import java.util.Date;
@@ -46,6 +47,7 @@ public class TestConfigurationFactory {
public static ScenarioBuilder createScenario() {
return scenario("simple").validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
+ .validate(schematron("Sample Schematron").source(Simple.SCHEMATRON))
.with(report("Report für eRechnung").source("report.xsl")).acceptWith("count(//test:rejected) = 0")
.declareNamespace("cri", "http://www.xoev.de/de/validator/framework/1/createreportinput")
.declareNamespace("rpt", "http://validator.kosit.de/test-report")
diff --git a/src/test/java/de/kosit/validationtool/docs/MiscDocExampleCodes.java b/src/test/java/de/kosit/validationtool/docs/MiscDocExampleCodes.java
new file mode 100644
index 0000000..ae8aa29
--- /dev/null
+++ b/src/test/java/de/kosit/validationtool/docs/MiscDocExampleCodes.java
@@ -0,0 +1,51 @@
+package de.kosit.validationtool.docs;
+
+import java.net.URI;
+
+import javax.xml.transform.URIResolver;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
+import de.kosit.validationtool.api.Configuration;
+import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
+import de.kosit.validationtool.impl.ResolvingMode;
+import de.kosit.validationtool.impl.xml.ProcessorProvider;
+import net.sf.saxon.lib.UnparsedTextURIResolver;
+
+public class MiscDocExampleCodes {
+
+ void m1() {
+ final Configuration config = Configuration.load(URI.create("myscenarios.xml")).setResolvingMode(ResolvingMode.STRICT_LOCAL)
+ .build(ProcessorProvider.getProcessor());
+ }
+
+ private static final class MyCustomResolvingConfigurationStrategy implements ResolvingConfigurationStrategy {
+
+ public SchemaFactory createSchemaFactory() {
+ // TODO
+ return null;
+ }
+
+ public URIResolver createResolver(final URI scenarioRepository) {
+ // TODO
+ return null;
+ }
+
+ public UnparsedTextURIResolver createUnparsedTextURIResolver(final URI scenarioRepository) {
+ // TODO
+ return null;
+ }
+
+ public Validator createValidator(final Schema schema) {
+ // TODO
+ return null;
+ }
+ }
+
+ void m2() {
+ final Configuration config = Configuration.load(URI.create("myscenarios.xml"))
+ .setResolvingStrategy(new MyCustomResolvingConfigurationStrategy()).build(ProcessorProvider.getProcessor());
+ }
+
+}
diff --git a/src/test/java/de/kosit/validationtool/docs/MyValidator.java b/src/test/java/de/kosit/validationtool/docs/MyValidator.java
new file mode 100644
index 0000000..7d4acd9
--- /dev/null
+++ b/src/test/java/de/kosit/validationtool/docs/MyValidator.java
@@ -0,0 +1,31 @@
+package de.kosit.validationtool.docs;
+
+import static de.kosit.validationtool.config.ConfigurationBuilder.fallback;
+import static de.kosit.validationtool.config.ConfigurationBuilder.report;
+import static de.kosit.validationtool.config.ConfigurationBuilder.scenario;
+import static de.kosit.validationtool.config.ConfigurationBuilder.schema;
+import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
+
+import java.net.URI;
+import java.nio.file.Paths;
+
+import de.kosit.validationtool.api.Check;
+import de.kosit.validationtool.api.Configuration;
+import de.kosit.validationtool.impl.DefaultCheck;
+import de.kosit.validationtool.impl.xml.ProcessorProvider;
+
+/**
+ * Example code that is used in the docs/api.md file
+ */
+public class MyValidator {
+
+ public static void main(final String[] args) {
+ final Configuration config = Configuration.create().name("myconfiguration")
+ .with(scenario("firstScenario").match("//myNode").validate(schema("Sample Schema").schemaLocation(URI.create("simple.xsd")))
+ .validate(schematron("my rules").source("myRules.xsl")).with(report("my report").source("report.xsl")))
+ .with(fallback().name("default-report").source("fallback.xsl")).useRepository(Paths.get("/opt/myrepository"))
+ .build(ProcessorProvider.getProcessor());
+ final Check validator = new DefaultCheck(config);
+ // .. run your checks
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/de/kosit/validationtool/docs/StandardExample.java b/src/test/java/de/kosit/validationtool/docs/StandardExample.java
new file mode 100644
index 0000000..71025fe
--- /dev/null
+++ b/src/test/java/de/kosit/validationtool/docs/StandardExample.java
@@ -0,0 +1,54 @@
+package de.kosit.validationtool.docs;
+
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.w3c.dom.Document;
+
+import de.kosit.validationtool.api.Check;
+import de.kosit.validationtool.api.Configuration;
+import de.kosit.validationtool.api.Input;
+import de.kosit.validationtool.api.InputFactory;
+import de.kosit.validationtool.api.Result;
+import de.kosit.validationtool.impl.DefaultCheck;
+import de.kosit.validationtool.impl.xml.ProcessorProvider;
+
+/**
+ * Example code that is used in the docs/api.md file
+ */
+public class StandardExample {
+
+ public void run(final Path testDocument) throws URISyntaxException {
+ // Load scenarios.xml from classpath
+ final URL scenarios = this.getClass().getClassLoader().getResource("examples/simple/scenarios-with-relative-paths.xml");
+ // Load the rest of the specific Validator configuration from classpath
+ final Configuration config = Configuration.load(scenarios.toURI()).build(ProcessorProvider.getProcessor());
+ // Use the default validation procedure
+ final Check validator = new DefaultCheck(config);
+ // Validate a single document
+ final Input document = InputFactory.read(testDocument);
+ // Get Result including information about the whole validation
+ final Result report = validator.checkInput(document);
+ System.out.println("Is processing succesful=" + report.isProcessingSuccessful());
+ // Get report document if processing was successful
+ Document result = null;
+ if (report.isProcessingSuccessful()) {
+ result = report.getReportDocument();
+ }
+ // continue processing results...
+ }
+
+ public static void main(final String[] args) throws Exception {
+ // Use e.g. "src/test/resources/examples/simple/input/foo.xml"
+ if (args.length == 0) {
+ throw new IllegalStateException("Provide a test document filename on the commandline");
+ }
+ // Path of document for validation
+ final Path testDoc = Paths.get(args[0]);
+ final StandardExample example = new StandardExample();
+ // run example validation
+ example.run(testDoc);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/de/kosit/validationtool/impl/Helper.java b/src/test/java/de/kosit/validationtool/impl/Helper.java
index 334791c..f60c8a1 100644
--- a/src/test/java/de/kosit/validationtool/impl/Helper.java
+++ b/src/test/java/de/kosit/validationtool/impl/Helper.java
@@ -32,7 +32,6 @@ import de.kosit.validationtool.impl.model.Result;
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
import de.kosit.validationtool.impl.xml.ProcessorProvider;
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
-
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.SaxonApiException;
import net.sf.saxon.s9api.Serializer;
@@ -52,16 +51,18 @@ public class Helper {
public static final URI EXAMPLES = ROOT.resolve("input/");
- public static final URI SIMPLE_VALID = Simple.ROOT.resolve("input/simple.xml");
+ public static final URI SIMPLE_VALID = ROOT.resolve("input/simple.xml");
- public static final URI FOO = Simple.ROOT.resolve("input/foo.xml");
+ public static final URI FOO = ROOT.resolve("input/foo.xml");
public static final URI FOO_SCHEMATRON_INVALID = EXAMPLES.resolve("foo-schematron-invalid.xml");
- public static final URI REJECTED = Simple.ROOT.resolve("input/withManualReject.xml");
+ public static final URI REJECTED = ROOT.resolve("input/withManualReject.xml");
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
+ public static final URI SCENARIOS_WITH_RELATIVE_PATHS = ROOT.resolve("scenarios-with-relative-paths.xml");
+
public static final URI OTHER_SCENARIOS = ROOT.resolve("otherScenarios.xml");
public static final URI ERROR_SCENARIOS = ROOT.resolve("scenarios-with-errors.xml");
@@ -84,6 +85,8 @@ public class Helper {
public static final URI SCHEMA = REPOSITORY_URI.resolve("simple.xsd");
+ public static final URI SCHEMATRON = REPOSITORY_URI.resolve("simple-schematron-error.xsl");
+
public static final ContentRepository createContentRepository() {
final ResolvingConfigurationStrategy strategy = ResolvingMode.STRICT_RELATIVE.getStrategy();
return new ContentRepository(Helper.getTestProcessor(), strategy, Simple.REPOSITORY_URI);
diff --git a/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java b/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java
index 17f6dfd..9bf99bc 100644
--- a/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java
+++ b/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java
@@ -77,7 +77,7 @@ public class CreateReportActionTest {
this.action.check(bag);
assertThat(bag.getReport()).isNotNull();
final String reportString = serialize(bag.getReport());
- assertThat(reportString).contains("SAXParseException");
+ assertThat(reportString).contains("SXXP0003");
}
@Test
diff --git a/src/test/resources/examples/resolving/withRemote.xsd b/src/test/resources/examples/resolving/withRemote.xsd
index 1811f74..1d458d8 100644
--- a/src/test/resources/examples/resolving/withRemote.xsd
+++ b/src/test/resources/examples/resolving/withRemote.xsd
@@ -18,9 +18,8 @@
-
+ schemaLocation="https://www.springframework.org/schema/context/spring-context.xsd" />
diff --git a/src/test/resources/examples/simple/scenarios-with-relative-paths.xml b/src/test/resources/examples/simple/scenarios-with-relative-paths.xml
new file mode 100644
index 0000000..ff2334b
--- /dev/null
+++ b/src/test/resources/examples/simple/scenarios-with-relative-paths.xml
@@ -0,0 +1,95 @@
+
+
+
+
+ HTML-TestSuite
+ QA
+ 2025-08-19
+
+