Commit aa931606 authored by R.W.Majeed's avatar R.W.Majeed
Browse files

fixed reporting of missing template files in art-decor releases

parent 0c2a7fda
......@@ -2,6 +2,7 @@ package org.aktin.cda;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
......@@ -9,7 +10,6 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.junit.Assert;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
......@@ -20,7 +20,7 @@ public class SchemaValidator {
public SchemaValidator() throws SAXException{
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL url = getClass().getResource("/schemas/CDA.xsd");
Assert.assertNotNull("CDA XSD resource not found from external release", url);
Objects.requireNonNull(url, "CDA XSD resource not found from external release");
this.schema = sf.newSchema(url);
}
......
......@@ -3,6 +3,7 @@ package org.aktin.cda;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Objects;
import java.util.logging.Logger;
import javax.xml.transform.OutputKeys;
......@@ -25,6 +26,7 @@ public class SingleTemplateValidator implements URIResolver{
public SingleTemplateValidator(URL svrlTransformation) throws IOException, TransformerConfigurationException{
this.svrlTransformation = svrlTransformation;
Objects.requireNonNull(svrlTransformation);
}
private void loadTransformer() throws TransformerConfigurationException{
......
......@@ -7,6 +7,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Logger;
import javax.inject.Singleton;
......@@ -69,11 +70,17 @@ public class Validator implements NamespaceContext{
} catch (XPathExpressionException e) {
throw new IOException(e);
}
addTemplateValidator("1.2.276.0.76.10.1015", getClass().getResource("/aktin-basism_svrl.xsl"));
addTemplateValidator("1.2.276.0.76.10.1019", getClass().getResource("/aktin-basism20152b_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");
}
private void addTemplateValidator(String templateId, String svrlTransformationResource) throws TransformerConfigurationException, IOException{
URL url = getClass().getResource(svrlTransformationResource);
Objects.requireNonNull(url, "Template resource not found in schematron-release: "+svrlTransformationResource);
addTemplateValidator(templateId, url);
}
private void addTemplateValidator(String templateId, URL svrlTransformation) throws TransformerConfigurationException, IOException{
templateValidators.put(templateId, new SingleTemplateValidator(svrlTransformation));
}
......
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