mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
make report optional
This commit is contained in:
parent
9f3ded6e5b
commit
55ec1dc560
4 changed files with 73 additions and 30 deletions
|
|
@ -69,6 +69,8 @@ public class ConfigurationLoader {
|
|||
|
||||
private static final String SUPPORTED_MAJOR_VERSION_SCHEMA = "http://www.xoev.de/de/validator/framework/1/scenarios";
|
||||
|
||||
protected final Map<String, Object> parameters = new HashMap<>();
|
||||
|
||||
/**
|
||||
* URL, die auf die scenerio.xml Datei zeigt.
|
||||
*/
|
||||
|
|
@ -84,16 +86,6 @@ public class ConfigurationLoader {
|
|||
|
||||
protected ResolvingConfigurationStrategy resolvingConfigurationStrategy;
|
||||
|
||||
protected final Map<String, Object> parameters = new HashMap<>();
|
||||
|
||||
URI getScenarioRepository() {
|
||||
if (this.scenarioRepository == null) {
|
||||
log.info("Creating default scenario repository (alongside scenario definition)");
|
||||
return RelativeUriResolver.resolve(URI.create("."), this.scenarioDefinition);
|
||||
}
|
||||
return this.scenarioRepository;
|
||||
}
|
||||
|
||||
private static void checkVersion(final URI scenarioDefinition, final Processor processor) {
|
||||
try {
|
||||
final Result<XdmNode, XMLSyntaxError> result = new DocumentParseAction(processor)
|
||||
|
|
@ -132,6 +124,38 @@ public class ConfigurationLoader {
|
|||
|
||||
}
|
||||
|
||||
private static List<Scenario> initializeScenarios(final Scenarios def, final ContentRepository contentRepository) {
|
||||
return def.getScenario().stream().map(s -> initialize(s, contentRepository)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static Scenario initialize(final ScenarioType def, final ContentRepository repository) {
|
||||
final Scenario s = new Scenario(def);
|
||||
s.setMatchExecutable(repository.createMatchExecutable(def));
|
||||
s.setSchema(repository.createSchema(def));
|
||||
s.setSchematronValidations(repository.createSchematronTransformations(def));
|
||||
if (def.getCreateReport() != null) {
|
||||
s.setReportTransformation(repository.createReportTransformation(def));
|
||||
} else {
|
||||
log.warn("No report configured. Will provide an internal format as report!");
|
||||
s.setReportTransformation(repository.createIdentityTransformation());
|
||||
}
|
||||
s.setFactory(repository.getResolvingConfigurationStrategy());
|
||||
s.setUriResolver(repository.getResolver());
|
||||
s.setUnparsedTextURIResolver(repository.getUnparsedTextURIResolver());
|
||||
if (def.getAcceptMatch() != null) {
|
||||
s.setAcceptExecutable(repository.createAccepptExecutable(def));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
URI getScenarioRepository() {
|
||||
if (this.scenarioRepository == null) {
|
||||
log.info("Creating default scenario repository (alongside scenario definition)");
|
||||
return RelativeUriResolver.resolve(URI.create("."), this.scenarioDefinition);
|
||||
}
|
||||
return this.scenarioRepository;
|
||||
}
|
||||
|
||||
public Configuration build(final Processor processor) {
|
||||
final ResolvingConfigurationStrategy resolving = getResolvingConfigurationStrategy();
|
||||
final ContentRepository contentRepository = new ContentRepository(processor, resolving, getScenarioRepository());
|
||||
|
|
@ -150,10 +174,6 @@ public class ConfigurationLoader {
|
|||
return (configuration);
|
||||
}
|
||||
|
||||
private static List<Scenario> initializeScenarios(final Scenarios def, final ContentRepository contentRepository) {
|
||||
return def.getScenario().stream().map(s -> initialize(s, contentRepository)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ResolvingConfigurationStrategy getResolvingConfigurationStrategy() {
|
||||
if (this.resolvingConfigurationStrategy != null) {
|
||||
log.info("Custom resolving strategy supplied. Please take care of xml security!");
|
||||
|
|
@ -179,21 +199,6 @@ public class ConfigurationLoader {
|
|||
|
||||
}
|
||||
|
||||
private static Scenario initialize(final ScenarioType def, final ContentRepository repository) {
|
||||
final Scenario s = new Scenario(def);
|
||||
s.setMatchExecutable(repository.createMatchExecutable(def));
|
||||
s.setSchema(repository.createSchema(def));
|
||||
s.setSchematronValidations(repository.createSchematronTransformations(def));
|
||||
s.setReportTransformation(repository.createReportTransformation(def));
|
||||
s.setFactory(repository.getResolvingConfigurationStrategy());
|
||||
s.setUriResolver(repository.getResolver());
|
||||
s.setUnparsedTextURIResolver(repository.getUnparsedTextURIResolver());
|
||||
if (def.getAcceptMatch() != null) {
|
||||
s.setAcceptExecutable(repository.createAccepptExecutable(def));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets actual {@link ResolvingMode}, when the validator needs to resolve stuff on startup.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package de.kosit.validationtool.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
|
@ -265,4 +266,18 @@ public class ContentRepository {
|
|||
public Transformation createSchematronTransformation(final ValidateWithSchematron validateWithSchematron) {
|
||||
return createTransformation(validateWithSchematron.getResource());
|
||||
}
|
||||
|
||||
public Transformation createIdentityTransformation() {
|
||||
final URL url = ContentRepository.class.getClassLoader().getResource("transform/identity.xsl");
|
||||
try ( final InputStream input = url.openStream() ) {
|
||||
final XsltCompiler xsltCompiler = getProcessor().newXsltCompiler();
|
||||
final XsltExecutable executable = xsltCompiler.compile(new StreamSource(input));
|
||||
final ResourceType resource = new ResourceType();
|
||||
resource.setName("identity");
|
||||
resource.setLocation(url.toString());
|
||||
return new Transformation(executable, resource);
|
||||
} catch (final IOException | SaxonApiException e) {
|
||||
throw new IllegalStateException("Error creating identity transformation", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue