Skip to content
Snippets Groups Projects
Commit cf8fd96f authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- refactoring, more explicite type in ValidationSchema

- added schemaInst assignment in ValidationSchema
- added debug handling in initParams()
parent 863747e6
No related branches found
No related tags found
No related merge requests found
Pipeline #3626 passed
......@@ -33,6 +33,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
......@@ -84,8 +86,8 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin {
assert (attr_strings.get(1).equals("namespace"));
assert (attr_strings.get(2).equals("schemaurl"));
var namespace = attr_list.get(1);
var url = attr_list.get(2);
ValidationSchema v = new ValidationSchema(namespace, schematype, url);
String url = attr_list.get(2);
ValidationSchema v = new ValidationSchema(namespace, schematype, new URL(url));
namespaceSchemaMap.add(v);
} else {
log.error("invalid entry(" + i + ") in namespace schema map file " + namespaceSchemaMapFile);
......@@ -130,6 +132,8 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin {
* @param initp parameter map
*/
public void initParams(Map<String, String> initp) {
var debugstr = initp.get("debug");
debug= (null != debugstr && debugstr.equals("true"));
if (debug) {
System.out.println(initp);
}
......@@ -168,7 +172,15 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin {
if (debug) {
System.out.println("found schema " + type);
}
var ele = new ValidationSchema(null, type, info.systemID);
ValidationSchema ele = null;
try {
ele = new ValidationSchema(null, type, new URL(info.systemID));
} catch (SAXException | MalformedURLException e) {
if (debug) {
System.out.println( e.getMessage() );
}
log.error( e.getMessage() );
}
optEle = Optional.of(ele);
}
} else {
......@@ -225,7 +237,7 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin {
if (debug) {
System.out.println("-> dtd detected, use catalog");
}
} else if (!schema.get().schemaURL.isBlank()) {
} else if (!schema.get().schemaURL.toString().isBlank()) {
if (debug) {
System.out.println("-> set schema to " + schema.get().schemaURL);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment