mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
109 lines
3 KiB
Java
109 lines
3 KiB
Java
/*
|
|
* Copyright 2017-2022 Koordinierungsstelle für IT-Standards (KoSIT)
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package de.kosit.validationtool.impl;
|
|
|
|
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 net.sf.saxon.lib.UnparsedTextURIResolver;
|
|
import net.sf.saxon.s9api.XPathExecutable;
|
|
import net.sf.saxon.s9api.XPathSelector;
|
|
import net.sf.saxon.s9api.XsltExecutable;
|
|
|
|
/**
|
|
* @author Andreas Penski
|
|
*/
|
|
@RequiredArgsConstructor
|
|
@Setter
|
|
@Getter
|
|
public class Scenario {
|
|
|
|
/**
|
|
* Runtime objects for a transformation e.g. schematron or report.
|
|
*/
|
|
@Getter
|
|
@Setter
|
|
@AllArgsConstructor
|
|
public static class Transformation {
|
|
|
|
private XsltExecutable executable;
|
|
|
|
private ResourceType resourceType;
|
|
}
|
|
|
|
private final ScenarioType configuration;
|
|
|
|
private Schema schema;
|
|
|
|
private boolean fallback;
|
|
|
|
private XPathExecutable matchExecutable;
|
|
|
|
private XPathExecutable acceptExecutable;
|
|
|
|
private ResolvingConfigurationStrategy factory;
|
|
|
|
private URIResolver uriResolver;
|
|
|
|
private UnparsedTextURIResolver unparsedTextURIResolver;
|
|
|
|
@Setter
|
|
private List<Transformation> schematronValidations;
|
|
|
|
private Transformation reportTransformation;
|
|
|
|
public List<Transformation> getSchematronValidations() {
|
|
// Must return a mutable list
|
|
if (this.schematronValidations == null) {
|
|
this.schematronValidations = new ArrayList<>();
|
|
}
|
|
return this.schematronValidations;
|
|
}
|
|
|
|
public String getName() {
|
|
return this.configuration.getName();
|
|
}
|
|
|
|
public XPathSelector getMatchSelector() {
|
|
if (this.matchExecutable == null) {
|
|
throw new IllegalStateException("No match executable supplied");
|
|
}
|
|
return this.matchExecutable.load();
|
|
}
|
|
|
|
/**
|
|
* Returns a new XPath selector for evaluating the {@link de.kosit.validationtool.api.AcceptRecommendation}.
|
|
*
|
|
* @return new selector
|
|
*/
|
|
public Optional<XPathSelector> getAcceptSelector() {
|
|
final XPathSelector selector = this.acceptExecutable != null ? this.acceptExecutable.load() : null;
|
|
return Optional.ofNullable(selector);
|
|
}
|
|
|
|
}
|