Open acollad1 opened 9 months ago
Here's the link to the Request Tracker ticket that spawned this request 73214
The user has a problem with the emissions JSON schema. In particular the schema uses a lookbehind assertion in the regular expression to validate the MATS unadjusted hourly value.
"MATSMonitorHourlyValue": {
"title": "MATSMonitorHourlyValue",
"type": "object",
"additionalProperties": true,
"properties": {
"parameterCode": {
"type": "string"
},
"unadjustedHourlyValue": {
"type": [
"string",
"null"
],
"minimum": 0,
"maximum": 30,
"pattern": "^[+\\-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d+)?(?:(?<=\\d)(?:[eE][+\\-]?\\d+))?$"
},
When this schema is imported into XML spy it complains that the regular expression is not valid.
The answer to this question is on this page https://json-schema.org/understanding-json-schema/reference/regular_expressions. Here is the excerpt:
The pattern and patternProperties keywords use regular expressions to express constraints. The regular expression syntax used is from JavaScript (ECMA 262, specifically). However, that complete syntax is not widely supported, therefore it is recommended that you stick to the subset of that syntax described below.
We did not follow this recommendation in defining the schema as the lookbehind assertion is not in the list of "recommended" syntax. My guess is the regular expression engine which is shipped with this users version of XML Spy does not support the full list of regex syntax in ECMA 262 that's why they get the error.
^((?!0.00)[-]?[0-9][.][0-9]{1,2}[E]([0]|[-]?[1-9][0-9]*)|0.00E0)$
^[+\\-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d+)?(?:(?<=\\d)(?:[eE][+\\-]?\\d+))?$
0.00E0 8.58E-2 -8.58E-2 -8.58E2 8.58E2 8.5E-2 -8.5E-2 8.5E2 -8.5E2 8.5E-20 8.58E2 0.00E0
8.58e2 +8.58E2 8.58E+2 +8.58E2 +8.58E+2 8.58 E2
0.00E2 8.5E-0 8.5E-00 8.5E-01 858E-2 85.8E-2 -8.580E-2 +8.580E-2 .858E-2 8.5.8E-2
Verified on dev using ORIS 628, 4
The issue is verified.
Purpose
Summary of Problem Understanding from Mike Heese's Comment
The user has a problem with the emissions JSON schema. In particular the schema uses a lookbehind assertion in the regular expression to validate the MATS unadjusted hourly value. When this schema is imported into XML Spy it complains that the regular expression is not valid. The JSON Schema Regular Expressions page indicates that the ECMA 262 syntax is used in the Pattern specifications, but the complete syntax is not widely supported.
The assumption is that the user's version of XML Spy does not support the full list of regex syntax in ECMA 262.
Read Research Results Comment
Conclusion
The lookbehind assertion is not actually needed to create a Regular Expression for Unadjusted Hourly Values, and the existing Unadjusted Hourly Value pattern allows invalid formats. The Unadjusted Hourly Value JSON pattern should use the following Regular Expression:
^((?!0.00)[-]?[0-9][.][0-9]{1,2}[E]([0]|[-]?[1-9][0-9]*)|0.00E0)$
Needed Changes
Update the "emissions.schema.json" in the easey-content repository.
Acceptance Tests