mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
(chore) Extends Result-API, provide more information about schematron results
This commit is contained in:
parent
e313bc6328
commit
2a9cdc551a
2 changed files with 23 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package de.kosit.validationtool.api;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.oclc.purl.dsdl.svrl.FailedAssert;
|
||||||
import org.oclc.purl.dsdl.svrl.SchematronOutput;
|
import org.oclc.purl.dsdl.svrl.SchematronOutput;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
|
@ -69,6 +70,13 @@ public interface Result {
|
||||||
*/
|
*/
|
||||||
List<SchematronOutput> getSchematronResult();
|
List<SchematronOutput> getSchematronResult();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link org.oclc.purl.dsdl.svrl.FailedAssert FailedAsserts} of a schematron evaluation.
|
||||||
|
*
|
||||||
|
* @return list of {@link org.oclc.purl.dsdl.svrl.FailedAssert FailedAsserts}, if any, empty list otherwise
|
||||||
|
*/
|
||||||
|
List<FailedAssert> getFailedAsserts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Liefert ein true, wenn keine Schema-Violations vorhanden sind.
|
* Liefert ein true, wenn keine Schema-Violations vorhanden sind.
|
||||||
*
|
*
|
||||||
|
|
@ -82,4 +90,11 @@ public interface Result {
|
||||||
* @return true wenn well-formed
|
* @return true wenn well-formed
|
||||||
*/
|
*/
|
||||||
boolean isWellformed();
|
boolean isWellformed();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if schematron has been checked and the result does not contain any {@link FailedAssert FailedAsserts}.
|
||||||
|
*
|
||||||
|
* @return true, if valid
|
||||||
|
*/
|
||||||
|
boolean isSchematronValid();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,12 +127,19 @@ public class DefaultResult implements Result {
|
||||||
*
|
*
|
||||||
* @return die {@link FailedAssert}
|
* @return die {@link FailedAssert}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<FailedAssert> getFailedAsserts() {
|
public List<FailedAssert> getFailedAsserts() {
|
||||||
return filterSchematronResult(FailedAssert.class);
|
return filterSchematronResult(FailedAssert.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> List<T> filterSchematronResult(final Class<T> type) {
|
private <T> List<T> filterSchematronResult(final Class<T> type) {
|
||||||
return getSchematronResult().stream().filter(type::isInstance).map(type::cast).collect(Collectors.toList());
|
return getSchematronResult() != null
|
||||||
|
? getSchematronResult().stream().filter(type::isInstance).map(type::cast).collect(Collectors.toList())
|
||||||
|
: Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSchematronValid() {
|
||||||
|
return getSchematronResult() != null && getFailedAsserts().isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue