# Configuration Files Validator - openSF examples The open Simulation Framework ([openSF](https://eop-cfi.esa.int/index.php/opensf)) relies on a well- defined set of interfaces that the participating modules have to adhere to. These interfaces are specified in the [E2E-ICD](https://eop-cfi.esa.int/Repo/PUBLIC/DOCUMENTATION/SYSTEM_SUPPORT_DOCS/PE-ID-ESA-GS-464%20Generic%20E2E%20Simulator%20ICD%20V1.4.2.pdf) document published by ESA. The configuration files validator is a Python tool for validating XML configuration files against XSD schemas and performing additional checks for specific conditions within the XML structure. The parameter full name and also the the consistency of min and max attributes in the XML file for specific parameter types are additional checks. The tool is an example of how to check some properties of configuration files without necessarily involving the OSFI support library. ## Requirements and installation The tool requirements are stated in the `pyproject.toml` file. At the time of this writing, it is compatible with Python 3.8 or newer in all platforms, and the only direct dependency is the [`xmlschema` library](https://github.com/sissaschool/xmlschema). In order to install the tool, you can use the `pip` tool included in most Python installations. * If using the **source** distribution (sdist), extract it and run the following command from the extracted folder: `python -m pip install .` * If using the **wheel** file (whl), simply run: `python -m pip install file.whl` where "file.whl" is the name of downloaded file e.g. "configfilevalidator-0.0.1-py3-none-any.whl". The `pip` tool will automatically download all dependencies and then install them and the tool. ## Command-line usage The tool provides flexibility through command-line arguments, allowing users to control various aspects of the validation process. The following optional arguments are available: * `-h`, `--help`: Show this help message and exit * `--xsd-file-path`: Path to the XSD schema file. If not provided, the default schema will be used. * `--show-dims-warning`: Show warning if dims is present for non-MATRIX/ARRAY types * `--stop-on-error`: Stop on first validation error or get all the possible errors Here are some usage examples: ```bash # Valid python -m configFileValidator path/to/xml/file.xml # Valid, with only some optional arguments specified python -m configFileValidator path/to/xml/file.xml --show-dims-warning # Also valid, with arguments not necessarily specified in order python -m configFileValidator path/to/xml/file.xml --stop-on-error --show-dims-warning ``` ## Checks performed as part of the validation The application performs the following checks as part of the validation process. Some checks are optional and can be enabled through command-line arguments: 1. **Full Name Parameter Check:** - Ensures that there are no duplicate fully named parameters within the XML structure. - This check is always perfomed. 2. **Consistency Check for Min and Max Attributes:** - Verifies the consistency of min and max attributes in the XML file for specific types. - The values of min/max must be valid values for the type, and if both are present, min is ≤ max. - Ensure that if the `min` and `max` attributes do not appear for types where it does not make sense (e.g. STRING). - This check is always performed. 3. **Structure type:** - If the parameter type is MATRIX or ARRAY, then the element can have children, while other types can only have text content. - For parameters of type MATRIX and ARRAY, the attribute `elementType` must be present. - Based on the value of the attribute `elementType`, ensures that the parameter value is of the appropriate type (string, integer, float, boolean, etc.). For example, if `elementType=INTEGER`, then the parameter value must be a integer. - This check is always performed. 3. **Dimensions Check:** - Checks if the `dims` attribute appears with a type that is not MATRIX or ARRAY (old vectors). - This check is optional. Note: The checks marked as optional can be activated using the corresponding command-line arguments.