diff --git a/include-metadata/TranslationTemplateBundle-EIDfadd4929-fa60-4781-b658-703bbfe3f4eb.xml b/include-metadata/TranslationTemplateBundle-EIDfadd4929-fa60-4781-b658-703bbfe3f4eb.xml
index d95e4136..e0307648 100644
--- a/include-metadata/TranslationTemplateBundle-EIDfadd4929-fa60-4781-b658-703bbfe3f4eb.xml
+++ b/include-metadata/TranslationTemplateBundle-EIDfadd4929-fa60-4781-b658-703bbfe3f4eb.xml
@@ -470,5 +470,11 @@
The recommended identifier 'http://inspire.ec.europa.eu/operation/download/GetSpatialDataSet' should be used for serving pre-defined Spatial Data Sets.
+
+
+
+ The WFS is not valid against the '{xsd}' schema. Reason: '{reason}'
+
+
diff --git a/service/dis-csw-core-soapui-project.xml b/service/dis-csw-core-soapui-project.xml
index 9c751b94..afd98c5a 100644
--- a/service/dis-csw-core-soapui-project.xml
+++ b/service/dis-csw-core-soapui-project.xml
@@ -1687,9 +1687,102 @@ if(defaultLanguage.size() != 1){
${#Project#serviceEndpoint}
-
+
- xsi:schemaLocation
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://schemas.opengis.net/csw/2.0/csw.xsd", "http://inspire.ec.europa.eu/schemas/inspire_ds/1.0/inspire_ds.xsd"];
+
+ if(xml.getNodeValue("/*:GetRecords/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:GetRecords/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }
diff --git a/service/ds-sos-pre-defined-soapui-project.xml b/service/ds-sos-pre-defined-soapui-project.xml
index 3e1f2654..ebbf196c 100644
--- a/service/ds-sos-pre-defined-soapui-project.xml
+++ b/service/ds-sos-pre-defined-soapui-project.xml
@@ -1205,9 +1205,102 @@ else if(defaultLanguage.size() != 1){
${#Project#serviceEndpoint}
-
+
- xsi:schemaLocation
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://schemas.opengis.net/sos/2.0/sos.xsd", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd"];
+
+ if(xml.getNodeValue("/*:ExtendedCapabilities/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:ExtendedCapabilities/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }
diff --git a/service/ds-wcs-core-soapui-project.xml b/service/ds-wcs-core-soapui-project.xml
index 0d83cecc..d2c1ac81 100644
--- a/service/ds-wcs-core-soapui-project.xml
+++ b/service/ds-wcs-core-soapui-project.xml
@@ -327,9 +327,102 @@ a.exists(
200
-
+
- xsi:schemaLocation
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://schemas.opengis.net/wcs/2.1/gml/wcsAll.xsd", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd"];
+
+ if(xml.getNodeValue("/*:GetCapabilities/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:GetCapabilities/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }
diff --git a/service/ds-wfs-direct-soapui-project.xml b/service/ds-wfs-direct-soapui-project.xml
index 24239a7d..1e31091b 100644
--- a/service/ds-wfs-direct-soapui-project.xml
+++ b/service/ds-wfs-direct-soapui-project.xml
@@ -523,16 +523,103 @@ a.equals("/*:WFS_Capabilities/@version", "Capabilities version", "2.0.0");30000
-
+
- import de.interactive_instruments.etf.suim.*;
-Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
-a.exists("/*:WFS_Capabilities/@*:schemaLocation", "TR.missingSchemaLocation");
-
-
-
-
- xsi:schemaLocation
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://schemas.opengis.net/wfs/2.0/wfs.xsd", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd"];
+
+ if(xml.getNodeValue("/*:WFS_Capabilities/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:WFS_Capabilities/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }
+
@@ -1438,7 +1525,7 @@ a.equals("/*:WFS_Capabilities/fes:Filter_Capabilities/fes:Conformance/fes:Constr
etf.version
- 1.0.4
+ 1.0.5
etf.last.editor
@@ -1458,7 +1545,7 @@ a.equals("/*:WFS_Capabilities/fes:Filter_Capabilities/fes:Conformance/fes:Constr
etf.last.update.date
- 2020-05-295T09:47:00
+ 2021-04-29T11:30:00
etf.dependency.ids
diff --git a/service/ds-wfs-pre-defined-soapui-project.xml b/service/ds-wfs-pre-defined-soapui-project.xml
index 351d0783..fd3f0e04 100644
--- a/service/ds-wfs-pre-defined-soapui-project.xml
+++ b/service/ds-wfs-pre-defined-soapui-project.xml
@@ -2479,16 +2479,103 @@ a.equals("/*:WFS_Capabilities/@version", "Capabilities version", "2.0.0");30000
-
+
- import de.interactive_instruments.etf.suim.*;
-Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
-a.exists("/*:WFS_Capabilities/@*:schemaLocation", "TR.missingSchemaLocation");
-
-
-
-
- xsi:schemaLocation
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://schemas.opengis.net/wfs/2.0/wfs.xsd", "http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd"];
+
+ if(xml.getNodeValue("/*:WFS_Capabilities/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:WFS_Capabilities/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }
+
@@ -3290,7 +3377,6 @@ int getHttpResponseCode(String url, def credentials){
return connection.getResponseCode();
}
-assert schemaLocations != null, "Response does not contain xsi:schemaLocation attribute!";
if(schemaLocations!=null) {
for(schemaLocation in schemaLocations) {
log.info("Checking "+schemaLocation);
@@ -5886,13 +5972,6 @@ Source:
-
-
- import de.interactive_instruments.etf.suim.*;
-Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
-a.isTrue("//*[contains(@*:schemaLocation,'inspire_dls.xsd')]", "TR.missingDownloadServiceSchema");
-
-
import de.interactive_instruments.etf.suim.*;
@@ -7775,7 +7854,7 @@ if (node != null){
etf.version
- 1.0.8
+ 1.0.10
etf.last.editor
@@ -7795,7 +7874,7 @@ if (node != null){
etf.last.update.date
- 2020-05-29T09:52:00
+ 2021-04-29T11:30:00
diff --git a/service/vs-wms-soapui-project.xml b/service/vs-wms-soapui-project.xml
index 768d4b48..6f9ba0bc 100644
--- a/service/vs-wms-soapui-project.xml
+++ b/service/vs-wms-soapui-project.xml
@@ -276,9 +276,102 @@ if(makeInitialRequest){
${#Project#serviceEndpoint}
-
+
- http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd
+ import javax.xml.transform.stream.StreamSource;
+ import javax.xml.validation.SchemaFactory;
+ import javax.xml.validation.Schema;
+ import javax.xml.validation.Validator
+ import javax.xml.XMLConstants;
+ import java.io.*;
+ import org.xml.sax.SAXException;
+ import de.interactive_instruments.etf.suim.*;
+ import com.eviware.soapui.support.XmlHolder;
+ import javax.xml.transform.Source;
+ Assert a = new Assert(messageExchange, context, log, Assert.INSPIRE_DS_NS);
+
+ XmlHolder xml = new XmlHolder(messageExchange.responseContentAsXml);
+ def xmlText = xml.getXml();
+ def xsds = ["http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd", "http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd"];
+
+ if(xml.getNodeValue("/*:ExtendedCapabilities/@*:schemaLocation") != null){
+ xsds = xml.getNodeValue("/*:ExtendedCapabilities/@*:schemaLocation");
+ def splittedXsds = xsds.split(" ");
+ validationProccess(xmlText, splittedXsds);
+ }else{
+ validationProccess(xmlText, xsds);
+ }
+
+ public void validationProccess(String xmlText, String[] xsds){
+ def errorMessages = [];
+ def isValid = false;
+ xsds.each{ xsd ->
+ errorMessages.add(hasValidSchema(xmlText, xsd))
+ }
+
+ for (i = 0; i < errorMessages.size() ; i++){
+ if(isValid == false && errorMessages[i] == "valid"){
+ isValid = true;
+ }
+ }
+
+ if(isValid == false){
+ xsds.each{ xsd ->
+ log.debug("xsd");
+ errorMessages.add(validateFile(xmlText, xsd))
+ }
+ }
+ }
+
+ public boolean validateFile(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ throw new TranslatableAssertionError('TR.XmlNotValidAgainstSchemaLocation', assertParams);
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ }
+ }
+
+ public String hasValidSchema(String xml, String strSchemaLocation) {
+ Source xmlFile = null;
+
+ try {
+ URL schemaFile = new URL(strSchemaLocation);
+ xmlFile = new StreamSource(createFile(xml));
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ Schema schema = schemaFactory.newSchema(schemaFile);
+ Validator validator = schema.newValidator();
+ validator.validate(xmlFile);
+ return "valid";
+
+ } catch (SAXException e) {
+ String[] assertParams = ['xsd', strSchemaLocation, 'reason', e.getLocalizedMessage()];
+ return "invalid";
+
+ } catch (IOException ioe) {
+ System.out.println("IOException");
+ return "invalid";
+ }
+ }
+
+ public File createFile(String file) throws IOException {
+ File tempFile = File.createTempFile("temporaryfile",".xml")
+ BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
+ writer.write(file);
+ writer.close()
+ return tempFile;
+ }