diff --git a/validator-core/src/main/java/fr/ign/validator/Context.java b/validator-core/src/main/java/fr/ign/validator/Context.java index 10ac03a4..3e223ffb 100644 --- a/validator-core/src/main/java/fr/ign/validator/Context.java +++ b/validator-core/src/main/java/fr/ign/validator/Context.java @@ -17,8 +17,8 @@ import fr.ign.validator.data.Document; import fr.ign.validator.data.DocumentFile; import fr.ign.validator.data.Row; +import fr.ign.validator.data.Table; import fr.ign.validator.data.file.MetadataFile; -import fr.ign.validator.data.file.SingleTableFile; import fr.ign.validator.error.ErrorCode; import fr.ign.validator.error.ErrorFactory; import fr.ign.validator.error.ErrorScope; @@ -448,7 +448,7 @@ public T getDataByType(Class clazz) { public ErrorScope getScope() { if (getDataByType(Attribute.class) != null) { return ErrorScope.FEATURE; - } else if (getDataByType(SingleTableFile.class) != null) { + } else if (getDataByType(Table.class) != null) { return ErrorScope.HEADER; } else if (getDataByType(MetadataFile.class) != null) { return ErrorScope.METADATA; @@ -464,6 +464,12 @@ public ErrorScope getScope() { * @return */ public String getFileName() { + // allows to group table in MultiTable using an # + Table table = getDataByType(Table.class); + if (table != null) { + return table.getRelativePath(); + } + DocumentFile documentFile = getDataByType(DocumentFile.class); if (documentFile != null) { return relativize(documentFile.getPath()); diff --git a/validator-core/src/main/java/fr/ign/validator/data/Table.java b/validator-core/src/main/java/fr/ign/validator/data/Table.java index d4ed3c38..8b81152f 100644 --- a/validator-core/src/main/java/fr/ign/validator/data/Table.java +++ b/validator-core/src/main/java/fr/ign/validator/data/Table.java @@ -45,6 +45,10 @@ public Table(FeatureType featureType, TableReader reader, String relativePath) { this.relativePath = relativePath; } + public String getRelativePath() { + return relativePath; + } + @Override public void validate(Context context) { context.beginData(this); diff --git a/validator-core/src/main/java/fr/ign/validator/data/file/MultiTableFile.java b/validator-core/src/main/java/fr/ign/validator/data/file/MultiTableFile.java index 4c75d3ab..8ce5999f 100644 --- a/validator-core/src/main/java/fr/ign/validator/data/file/MultiTableFile.java +++ b/validator-core/src/main/java/fr/ign/validator/data/file/MultiTableFile.java @@ -65,7 +65,7 @@ protected void validateContent(Context context) { ); context.report( context.createError(CoreErrorCodes.MULTITABLE_UNEXPECTED) - .setMessageParam("FILEPATH", relativePath) + .setMessageParam("TABLENAME", tableName) ); continue; } diff --git a/validator-core/src/main/java/fr/ign/validator/validation/file/XsdSchemaValidator.java b/validator-core/src/main/java/fr/ign/validator/validation/file/XsdSchemaValidator.java index 09ba6b03..582cf0f4 100644 --- a/validator-core/src/main/java/fr/ign/validator/validation/file/XsdSchemaValidator.java +++ b/validator-core/src/main/java/fr/ign/validator/validation/file/XsdSchemaValidator.java @@ -82,9 +82,10 @@ public void warning(SAXParseException e) { } private void report(SAXParseException e) { + // TODO retrieve more information from the exception context.report( context.createError(CoreErrorCodes.XSD_SCHEMA_ERROR) - .setMessageParam("LINE_NUMBER", "#" + e.getLineNumber()) + .setId(String.valueOf(e.getLineNumber())) // line number .setMessageParam("MESSAGE", e.getMessage()) ); } diff --git a/validator-core/src/main/resources/error-code.json b/validator-core/src/main/resources/error-code.json index f090120c..b596692b 100644 --- a/validator-core/src/main/resources/error-code.json +++ b/validator-core/src/main/resources/error-code.json @@ -72,8 +72,8 @@ { "name": "XSD_SCHEMA_ERROR", "level": "ERROR", - "message": "{LINE_NUMBER} : {MESSAGE}", - "documentation": "Cette erreur se produit lors du nom respect d'un schéma XSD" + "message": "{MESSAGE}", + "documentation": "Cette erreur se produit lors du nom respect d'un schéma XSD associé à un fichier XML/GML" }, { "name": "TABLE_MISSING_ATTRIBUTE", @@ -108,8 +108,8 @@ { "name": "MULTITABLE_UNEXPECTED", "level": "WARNING", - "message": "La table '{FILEPATH}' n'est pas prévue dans le modèle de validation.", - "documentation": "" + "message": "La table '{TABLENAME}' n'est pas prévue dans le modèle de validation.", + "documentation": "Une table est présente dans un fichier multi-table sans être définie dans le modèle. Elle est ignorée pour la validation, la normalisation et le calcul de statistique." }, { "name": "ATTRIBUTE_UNEXPECTED_NULL", diff --git a/validator-core/src/test/java/fr/ign/validator/validation/file/XsdSchemaValidatorRegressTest.java b/validator-core/src/test/java/fr/ign/validator/validation/file/XsdSchemaValidatorRegressTest.java index 35c11e30..4c1051e3 100644 --- a/validator-core/src/test/java/fr/ign/validator/validation/file/XsdSchemaValidatorRegressTest.java +++ b/validator-core/src/test/java/fr/ign/validator/validation/file/XsdSchemaValidatorRegressTest.java @@ -14,6 +14,7 @@ import fr.ign.validator.Context; import fr.ign.validator.error.CoreErrorCodes; import fr.ign.validator.error.ErrorLevel; +import fr.ign.validator.error.ErrorScope; import fr.ign.validator.error.ValidatorError; import fr.ign.validator.model.Projection; import fr.ign.validator.report.InMemoryReportBuilder; @@ -37,7 +38,7 @@ public void setUp() { context = new Context(); report = new InMemoryReportBuilder(); context.setReportBuilder(report); - context.setProjection(Projection.CODE_CRS84); // TODO + context.setProjection(Projection.CODE_CRS84); /* to access XML schema */ Networking.configureHttpClient(); @@ -95,10 +96,13 @@ public void testValidateGmlInfoPctInvalid() throws MalformedURLException { { ValidatorError error = report.getErrorsByCode(CoreErrorCodes.XSD_SCHEMA_ERROR).get(0); assertEquals(ErrorLevel.ERROR, error.getLevel()); + assertEquals(ErrorScope.DIRECTORY, error.getScope()); + // check line number + assertEquals("26", error.getId()); // see https://wiki.xmldation.com/Support/Validator/cvc-complex-type-2-4-d assertTrue( "unexpected message : " + error.getMessage(), - error.getMessage().startsWith("#26 : cvc-complex-type.2.4.d") + error.getMessage().startsWith("cvc-complex-type.2.4.d") ); } }