mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
cleanup
This commit is contained in:
parent
2c479eded5
commit
7abc072911
2 changed files with 3 additions and 73 deletions
|
|
@ -1,69 +0,0 @@
|
||||||
package de.kosit.validationtool.cmd;
|
|
||||||
|
|
||||||
import static de.kosit.validationtool.config.ConfigurationBuilder.defaultFallback;
|
|
||||||
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 javax.xml.validation.Schema;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.api.Configuration;
|
|
||||||
import de.kosit.validationtool.config.FallbackBuilder;
|
|
||||||
import de.kosit.validationtool.config.ScenarioBuilder;
|
|
||||||
import de.kosit.validationtool.impl.ResolvingMode;
|
|
||||||
|
|
||||||
import net.sf.saxon.s9api.XPathExecutable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Andreas Penski
|
|
||||||
*/
|
|
||||||
public class DemoBuilder {
|
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
|
||||||
final XPathExecutable xpath = null;
|
|
||||||
// @formatter:off
|
|
||||||
Configuration
|
|
||||||
.create()
|
|
||||||
.name("some config")
|
|
||||||
.resolvingMode(ResolvingMode.JDK_SUPPORTED)
|
|
||||||
.with(scenario("s1").match("//name").validate(schema("http://some.schema.url")).description("some desc"))
|
|
||||||
.with(scenario("s2")
|
|
||||||
.match(xpath)
|
|
||||||
.acceptWith(xpath)
|
|
||||||
.validate(schema(URI.create("http://some.other.schema.url")))
|
|
||||||
.validate(schematron("some checks").source("some-schematron.xsl"))
|
|
||||||
.with(report("myReport").source(URI.create("some.xsl")))
|
|
||||||
.description("some desc"))
|
|
||||||
.with(defaultFallback())
|
|
||||||
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
.create()
|
|
||||||
.name("xrechnung")
|
|
||||||
.resolvingMode(ResolvingMode.STRICT_LOCAL)
|
|
||||||
.with( ubl() )
|
|
||||||
.with(cii())
|
|
||||||
.with( myFallback())
|
|
||||||
.build();
|
|
||||||
// @formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ScenarioBuilder cii() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FallbackBuilder myFallback() {
|
|
||||||
return new FallbackBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ScenarioBuilder ubl() {
|
|
||||||
final Schema schema = null; // load somehow
|
|
||||||
final ScenarioBuilder ubl = scenario("ubl");
|
|
||||||
ubl.validate(schema("someSchema", schema));
|
|
||||||
return ubl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,8 +6,7 @@ import javax.xml.XMLConstants;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
import javax.xml.validation.Validator;
|
import javax.xml.validation.Validator;
|
||||||
|
|
||||||
import org.xml.sax.SAXNotRecognizedException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.SAXNotSupportedException;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
@ -61,7 +60,7 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
|
||||||
private void setProperty(final PropertySetter setter, final boolean lenient, final String errorMessage) {
|
private void setProperty(final PropertySetter setter, final boolean lenient, final String errorMessage) {
|
||||||
try {
|
try {
|
||||||
setter.apply();
|
setter.apply();
|
||||||
} catch (final SAXNotRecognizedException | SAXNotSupportedException e) {
|
} catch (final SAXException e) {
|
||||||
|
|
||||||
if (lenient) {
|
if (lenient) {
|
||||||
log.warn(errorMessage);
|
log.warn(errorMessage);
|
||||||
|
|
@ -117,6 +116,6 @@ public abstract class BaseResolvingStrategy implements ResolvingConfigurationStr
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
private interface PropertySetter {
|
private interface PropertySetter {
|
||||||
|
|
||||||
void apply() throws SAXNotRecognizedException, SAXNotSupportedException;
|
void apply() throws SAXException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue