Commit fdc22f9b authored by R.W.Majeed's avatar R.W.Majeed

new schematron validation release.

allow info messages in validation response
parent 38257287
......@@ -19,5 +19,9 @@ public class ValidationErrorsToOperationOutcome implements ValidationErrorHandle
public void error(String message, Throwable cause) {
outcome.addIssue(Severity.error, IssueType.exception, message);
}
@Override
public void info(String message) {
outcome.addIssue(Severity.information, IssueType.informational, message);
}
}
......@@ -17,7 +17,7 @@ public class ValidationErrorsToRegistryError implements ValidationErrorHandler{
e.setSeverity(XDSConstants.SEVERITY_WARNING);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
rel.getRegistryError().add(e);
}
@Override
......@@ -26,7 +26,15 @@ public class ValidationErrorsToRegistryError implements ValidationErrorHandler{
e.setSeverity(XDSConstants.SEVERITY_ERROR);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
rel.getRegistryError().add(e);
}
@Override
public void info(String message) {
RegistryError e = new RegistryError();
e.setSeverity(XDSConstants.SEVERITY_WARNING);
e.setCodeContext(message); // free error message
e.setErrorCode(XDSConstants.ERR_DOC_INVALID_CONTENT);
rel.getRegistryError().add(e);
}
}
......@@ -12,8 +12,8 @@
<version>0.13-SNAPSHOT</version>
</parent>
<properties>
<schematronVersion>20170302T140447</schematronVersion>
<examplesVersion>20170105T160149</examplesVersion>
<schematronVersion>20180323T201638</schematronVersion>
<examplesVersion>20180322T121703</examplesVersion>
<schematronArchive>aktin-runtime-${schematronVersion}</schematronArchive>
<examplesArchive>aktin-xml-${examplesVersion}</examplesArchive>
</properties>
......
......@@ -4,5 +4,6 @@ public interface ValidationErrorHandler {
void warning(String message, Throwable cause);
void error(String message, Throwable cause);
void info(String message);
}
......@@ -10,7 +10,8 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
private String systemId;
@Override
public void warning(String message, Throwable cause) {
System.err.println("Validation warning for "+systemId);
System.err.print("Validation WARNING for "+systemId+": ");
System.err.println(message);
if( cause != null ){
cause.printStackTrace();
}
......@@ -18,7 +19,8 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
@Override
public void error(String message, Throwable cause) {
System.err.println("Validation ERROR for "+systemId);
System.err.print("Validation ERROR for "+systemId+": ");
System.err.println(message);
if( cause != null ){
cause.printStackTrace();
}
......@@ -26,4 +28,10 @@ public class ValidationErrorPrinter implements ValidationErrorHandler {
public void setSystemId(String systemId){
this.systemId = systemId;
}
@Override
public void info(String message) {
System.err.print("Validation INFO for "+systemId+": ");
System.err.println(message);
}
}
......@@ -70,7 +70,7 @@ public class Validator implements NamespaceContext{
} catch (XPathExpressionException e) {
throw new IOException(e);
}
addTemplateValidator("1.2.276.0.76.10.1015", "/aktin-basism_svrl.xsl");
//addTemplateValidator("1.2.276.0.76.10.1015", "/aktin-basism_svrl.xsl");
addTemplateValidator("1.2.276.0.76.10.1019", "/aktin-basism20152b_svrl.xsl");
}
......@@ -112,11 +112,14 @@ public class Validator implements NamespaceContext{
errorCount ++;
handler.error(messageText, null);
break;
case "info":
handler.info(messageText);
break;
default:
log.warning("Unexpected failed-assert/@role="+role);
// fall through to warning
case "warning":
handler.error(messageText, null);
handler.warning(messageText, null);
}
}
return errorCount;
......
......@@ -12,4 +12,7 @@ public class SuppressValidationErrors implements ValidationErrorHandler{
@Override
public void error(String message, Throwable cause) {
}
@Override
public void info(String message) {
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ public class TestValidator {
public static final String[] v2ExampleDocuments = new String[]{
"/Additional Examples/basismodul-v2-beispiel-storyboard01-complete.xml",
"/Additional Examples/basismodul-v2-beispiel-storyboard01-minimal.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard01.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard02.xml",
"/CDA Beispiele Basis-Modul v2/basismodul-v2-beispiel-storyboard04.xml",
......@@ -63,27 +64,29 @@ public class TestValidator {
Assert.assertFalse("Validation failure expected for "+example, isValid);
}
}
for( String example : v1InvalidExampleDocuments ){
p.setSystemId(example);
try( InputStream in = getClass().getResourceAsStream(example) ){
Assert.assertTrue(in.available() > 0);
boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, SuppressValidationErrors.staticInstance);
Assert.assertFalse("Validation failure expected for "+example, isValid);
}
}
for( String example : v1ExampleDocuments ){
p.setSystemId(example);
try( InputStream in = getClass().getResourceAsStream(example) ){
Assert.assertTrue(in.available() > 0);
boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, p);
if( !isValid ){
Assert.fail("Successful validation expected for "+example);
}
}
}
// v1 no longer supported
// for( String example : v1InvalidExampleDocuments ){
// p.setSystemId(example);
// try( InputStream in = getClass().getResourceAsStream(example) ){
// Assert.assertTrue(in.available() > 0);
// boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, SuppressValidationErrors.staticInstance);
// Assert.assertFalse("Validation failure expected for "+example, isValid);
// }
// }
// for( String example : v1ExampleDocuments ){
// p.setSystemId(example);
// try( InputStream in = getClass().getResourceAsStream(example) ){
// Assert.assertTrue(in.available() > 0);
// boolean isValid = v.validate(parser.buildDOM(new StreamSource(in)), v1TemplateId, p);
// if( !isValid ){
// Assert.fail("Successful validation expected for "+example);
// }
// }
// }
}
@Test
//@Test
public void validateErrorsForOtherDocuments() throws Exception{
Validator v = new Validator();
CDAParser parser = new CDAParser();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment