mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
(enhance) ContentRepository is only based on uri and strategy
This commit is contained in:
parent
35c0797898
commit
7ca3ef90f3
9 changed files with 38 additions and 42 deletions
|
|
@ -172,10 +172,7 @@ public class ConfigurationBuilder {
|
|||
if (this.processor == null) {
|
||||
this.processor = resolving.createProcessor();
|
||||
}
|
||||
final ContentRepository contentRepository = new ContentRepository(this.processor, this.repository,
|
||||
resolving.createResolver(this.repository));
|
||||
contentRepository.setSchemaFactory(resolving.createSchemaFactory());
|
||||
contentRepository.setResolvingConfigurationStrategy(resolving);
|
||||
final ContentRepository contentRepository = new ContentRepository(this.resolvingConfigurationStrategy, this.repository);
|
||||
|
||||
final List<Scenario> list = initializeScenarios(contentRepository);
|
||||
final Scenario fallbackScenario = initializeFallback(contentRepository);
|
||||
|
|
|
|||
|
|
@ -118,10 +118,7 @@ public class ConfigurationLoader {
|
|||
public Configuration build() {
|
||||
final ResolvingConfigurationStrategy resolving = getResolvingConfigurationStrategy();
|
||||
final Processor processor = resolving.createProcessor();
|
||||
final ContentRepository contentRepository = new ContentRepository(processor, getScenarioRepository(),
|
||||
resolving.createResolver(this.getScenarioRepository()));
|
||||
contentRepository.setSchemaFactory(resolving.createSchemaFactory());
|
||||
contentRepository.setResolvingConfigurationStrategy(resolving);
|
||||
final ContentRepository contentRepository = new ContentRepository(resolving, getScenarioRepository());
|
||||
|
||||
final Scenarios def = loadScenarios(contentRepository.getScenarioSchema(), processor);
|
||||
final List<Scenario> scenarios = initializeScenarios(def, contentRepository);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import org.xml.sax.SAXException;
|
|||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||
|
|
@ -78,13 +77,27 @@ public class ContentRepository {
|
|||
|
||||
private final URIResolver resolver;
|
||||
|
||||
@Setter
|
||||
private SchemaFactory schemaFactory;
|
||||
private final SchemaFactory schemaFactory;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private ResolvingConfigurationStrategy resolvingConfigurationStrategy;
|
||||
private final ResolvingConfigurationStrategy resolvingConfigurationStrategy;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ContentRepository} based on configured security and resolving strategy and the specified
|
||||
* repository location.
|
||||
*
|
||||
* @param strategy the security and resolving strategy
|
||||
* @param repository the repository.
|
||||
*/
|
||||
public ContentRepository(final ResolvingConfigurationStrategy strategy, final URI repository) {
|
||||
this.repository = repository;
|
||||
this.resolvingConfigurationStrategy = strategy;
|
||||
this.processor = this.resolvingConfigurationStrategy.createProcessor();
|
||||
this.resolver = this.resolvingConfigurationStrategy.createResolver(repository);
|
||||
this.schemaFactory = this.resolvingConfigurationStrategy.createSchemaFactory();
|
||||
}
|
||||
|
||||
@SuppressWarnings("java:S2095")
|
||||
private static Source resolve(final URL resource) {
|
||||
try {
|
||||
return new StreamSource(resource.openStream(), resource.toURI().getRawPath());
|
||||
|
|
@ -119,10 +132,9 @@ public class ContentRepository {
|
|||
final CollectingErrorEventHandler listener = new CollectingErrorEventHandler();
|
||||
try {
|
||||
xsltCompiler.setErrorListener(listener);
|
||||
final URIResolver resolver = getResolver();
|
||||
if (resolver != null) {
|
||||
if (getResolver() != null) {
|
||||
// otherwise use default resolver
|
||||
xsltCompiler.setURIResolver(resolver);
|
||||
xsltCompiler.setURIResolver(getResolver());
|
||||
}
|
||||
|
||||
return xsltCompiler.compile(resolveInRepository(uri));
|
||||
|
|
@ -275,7 +287,7 @@ public class ContentRepository {
|
|||
}
|
||||
|
||||
public List<Transformation> createSchematronTransformations(final ScenarioType s) {
|
||||
return s.getValidateWithSchematron() != null && s.getValidateWithSchematron().isEmpty() ? Collections.emptyList()
|
||||
return s.getValidateWithSchematron().isEmpty() ? Collections.emptyList()
|
||||
: s.getValidateWithSchematron().stream().map(this::createSchematronTransformation).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import java.net.URI;
|
|||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
|
@ -144,8 +143,8 @@ public class ObjectFactory {
|
|||
Transformer transformer = null;
|
||||
try {
|
||||
final TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); // Compliant
|
||||
// transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
|
||||
// transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); // Compliant
|
||||
transformer = transformerFactory.newTransformer();
|
||||
if (prettyPrint) {
|
||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue