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

- performance fix, load only schemaInst if needed

parent bae8d55b
No related branches found
No related tags found
No related merge requests found
Pipeline #3629 passed
...@@ -31,6 +31,7 @@ import javax.xml.XMLConstants; ...@@ -31,6 +31,7 @@ import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import javax.xml.validation.SchemaFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
...@@ -242,7 +243,8 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin { ...@@ -242,7 +243,8 @@ public class SLUBXmlFormatValidationPlugin implements FormatValidationPlugin {
if (debug) { if (debug) {
System.out.println("-> set schema to " + schema.get().schemaURL); System.out.println("-> set schema to " + schema.get().schemaURL);
} }
dbf.setSchema(schema.get().schemaInst); var schemaInst = SchemaFactory.newDefaultInstance().newSchema( schema.get().schemaURL );
dbf.setSchema(schemaInst);
assert(dbf.getSchema() != null); assert(dbf.getSchema() != null);
} }
valid = validateAgainstSchema(filePath); valid = validateAgainstSchema(filePath);
......
...@@ -2,20 +2,16 @@ package org.slub.rosetta.dps.repository.plugin; ...@@ -2,20 +2,16 @@ package org.slub.rosetta.dps.repository.plugin;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.net.URL; import java.net.URL;
class ValidationSchema { class ValidationSchema {
public final String nameSpace; public final String nameSpace;
public final ValidationSchemaType schemaType; public final ValidationSchemaType schemaType;
public final URL schemaURL; public final URL schemaURL;
public Schema schemaInst;
public ValidationSchema(String nameSpace, ValidationSchemaType schemaType, URL schemaURL) throws SAXException { public ValidationSchema(String nameSpace, ValidationSchemaType schemaType, URL schemaURL) throws SAXException {
this.nameSpace = nameSpace; this.nameSpace = nameSpace;
this.schemaURL = schemaURL; this.schemaURL = schemaURL;
this.schemaType = schemaType; this.schemaType = schemaType;
this.schemaInst = SchemaFactory.newDefaultInstance().newSchema( schemaURL );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment