diff --git a/app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/SclValidatorServerEndpointTest.java b/app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/SclValidatorServerEndpointTest.java
index e27d885..83fe697 100644
--- a/app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/SclValidatorServerEndpointTest.java
+++ b/app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/SclValidatorServerEndpointTest.java
@@ -38,7 +38,7 @@ class SclValidatorServerEndpointTest {
@InjectMock
private SclValidatorService sclValidatorService;
- @TestHTTPResource("/compas-scl-validator/validate-ws/v1/SCD")
+ @TestHTTPResource("/validate-ws/v1/SCD")
private URI uri;
@Test
diff --git a/pom.xml b/pom.xml
index 015aac8..2ed57be 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,8 +26,8 @@ SPDX-License-Identifier: Apache-2.0
0.0.4
0.9.3
- 2.12.2.Final
- 2.0.1
+ 2.13.0.Final
+ 2.0.3
0.9.1
diff --git a/riseclipse/riseclipse-p2-to-m2/pom.xml b/riseclipse/riseclipse-p2-to-m2/pom.xml
index b1d9bed..bffc04d 100644
--- a/riseclipse/riseclipse-p2-to-m2/pom.xml
+++ b/riseclipse/riseclipse-p2-to-m2/pom.xml
@@ -29,7 +29,7 @@ SPDX-License-Identifier: Apache-2.0
org.eclipse.tycho.extras
tycho-eclipserun-plugin
- 2.7.5
+ 3.0.0
${project.build.directory}/maven/tmp/cbi
JavaSE-17
diff --git a/validator/src/main/java/org/lfenergy/compas/scl/validator/xsd/XSDValidator.java b/validator/src/main/java/org/lfenergy/compas/scl/validator/xsd/XSDValidator.java
index 9a5344c..d2e6302 100644
--- a/validator/src/main/java/org/lfenergy/compas/scl/validator/xsd/XSDValidator.java
+++ b/validator/src/main/java/org/lfenergy/compas/scl/validator/xsd/XSDValidator.java
@@ -12,6 +12,7 @@
import org.xml.sax.SAXException;
import javax.xml.XMLConstants;
+import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
@@ -35,10 +36,12 @@ public XSDValidator(List errorList, String sclData) {
var sclVersion = info.getSclVersion();
try {
+ var sclXsd = new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL" + sclVersion + "/SCL.xsd"));
+ var compasXsd = new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL_CoMPAS.xsd"));
+
var factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
factory.setResourceResolver(new ResourceResolver(sclVersion));
- var schema = factory.newSchema(
- new StreamSource(getClass().getClassLoader().getResourceAsStream("xsd/SCL" + sclVersion + "/SCL.xsd")));
+ var schema = factory.newSchema(new Source[]{sclXsd, compasXsd});
validator = schema.newValidator();
validator.setErrorHandler(new XSDErrorHandler(errorList));
} catch (SAXException exception) {
diff --git a/validator/src/test/java/org/lfenergy/compas/scl/validator/xsd/XSDValidatorTest.java b/validator/src/test/java/org/lfenergy/compas/scl/validator/xsd/XSDValidatorTest.java
index 199b1fb..6f53466 100644
--- a/validator/src/test/java/org/lfenergy/compas/scl/validator/xsd/XSDValidatorTest.java
+++ b/validator/src/test/java/org/lfenergy/compas/scl/validator/xsd/XSDValidatorTest.java
@@ -46,6 +46,32 @@ void validate_WhenCalledWithSclDataWithXsdValidationErrors_ThenErrorsAreRetrieve
}
}
+ @Test
+ void validate_WhenCalledWithSclDataWithCompasXsdValidationErrors_ThenErrorsAreRetrieved() throws IOException {
+ var errorList = new ArrayList();
+ try (var inputStream = getClass()
+ .getResourceAsStream("/scl/validation/example-with-compas-validation-errors.scd")) {
+ var data = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
+ new XSDValidator(errorList, data).validate();
+
+ assertEquals(4, errorList.size());
+
+ var error = errorList.get(0);
+ assertEquals("Value 'INVALID' is not facet-valid with respect to enumeration '[SSD, IID, ICD, SCD, CID, " +
+ "SED, ISD, STD]'. It must be a value from the enumeration.", error.getMessage());
+ assertEquals("XSD/cvc-enumeration-valid", error.getRuleName());
+ assertEquals(10, error.getLineNumber());
+ assertEquals(57, error.getColumnNumber());
+
+ error = errorList.get(2);
+ assertEquals("Value 'Invalid Label' is not facet-valid with respect to pattern '[A-Za-z][0-9A-Za-z_-]*' " +
+ "for type 'tCompasLabel'.", error.getMessage());
+ assertEquals("XSD/cvc-pattern-valid", error.getRuleName());
+ assertEquals(12, error.getLineNumber());
+ assertEquals(55, error.getColumnNumber());
+ }
+ }
+
@Test
void validate_WhenCalledWithSclDataContainingInvalidVersion_ThenExceptionIsThrown() throws IOException {
var errorList = new ArrayList();
diff --git a/validator/src/test/resources/scl/validation/example-with-compas-validation-errors.scd b/validator/src/test/resources/scl/validation/example-with-compas-validation-errors.scd
new file mode 100644
index 0000000..84824ea
--- /dev/null
+++ b/validator/src/test/resources/scl/validation/example-with-compas-validation-errors.scd
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+ MiniGrid
+ INVALID
+
+ Invalid Label
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IEC 61850-7-3:2007B
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IEC 61850-8-1:2003
+
+
+
+
+ IEC 61850-8-1:2003
+
+
+
+
+ IEC 61850-8-1:2003
+
+
+ Completed
+ Cancelled
+ New adjustments
+ AnotherValue
+
+
+ Va
+ Vb
+ Vc
+ Aa
+ Ab
+ Ac
+ Vab
+ Vbc
+ Vca
+ AnotherValue
+
+
+
\ No newline at end of file