Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync up the branches #546

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 26 additions & 23 deletions docs/source/Appendix_B.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,15 @@ when the planned XSD validation is implemented start with HED_XML.
**a.** An attribute is used in the schema, but is not defined in the schema attribute section.
**b.** A schema attribute is applied to the incorrect type (e.g., an element with the unit definition does appear
under an appropriate unit class).
**c.** A schema attribute is used in an invalid way

| Attribute | Invalid Usage Location |
|--------------------|----------------------------------------------------------------------------------------------------------------|
| `deprecatedFrom` | An element with a `deprecatedFrom` attribute has a child node that does not have a `deprecatedFrom` attribute. |
| `rooted` | See [SCHEMA_LIBRARY_INVALID](#SCHEMA_LIBRARY_INVALID) |
| `takesValue` | Used on a non-placeholder(#) node. |
| `unitClass` | Used on a non-placeholder(#) node. |
| `valueClass` | Used on a non-placeholder(#) node. |

**Note:**
- A `tag` element can have schema attributes that have the `nodeClassProperty` or the `elementProperty` or have no type property designator.
Expand All @@ -368,20 +377,20 @@ under an appropriate unit class).

#### SCHEMA_ATTRIBUTE_VALUE_INVALID

**a.** A non-boolean schema attribute has an invalid value as indicated by the following table.
**a.** A non-boolean schema attribute has an invalid value or usage as indicated by the following table.

| Attribute | Invalid attribute value |
| --------- |------------------------------------------------------------------------------------|
| Attribute | Invalid Attribute Value |
|-----------------|------------------------------------------------------------------------------------|
| `allowedCharacter` | Not a single character or one of:<br>`letters`, `blank`, `digits`, `alphanumeric`. |
| `conversionFactor` | Not a positive numeric value. |
| `defaultUnits` | Not a valid unit in this unit class. |
| `deprecatedFrom` | Not a valid semantic version number not later than current schema version. |
| `inLibrary` | |
| `relatedTag` | |
| `rooted` | |
| `suggestedTag` | |
| `unitClass` | |
| `valueClass` | |
| `conversionFactor` | Not a positive numeric value. |
| `defaultUnits` | Not a valid unit in this unit class. |
| `deprecatedFrom` | Does not correspond to a valid schema version. |
| `inLibrary` | The value of an inLibrary attribute is for the wrong library. |
| `relatedTag` | Not an existing tag. |
| `rooted` | See [SCHEMA_LIBRARY_INVALID](#SCHEMA_LIBRARY_INVALID) |
| `suggestedTag` | Not an existing tag. |
| `unitClass` | Not an existing unit class. |
| `valueClass` | Not an existing value class. |


#### SCHEMA_CHARACTER_INVALID
Expand Down Expand Up @@ -412,8 +421,8 @@ Library schema errors are specific to library schema. Library schema may also ra
#### SCHEMA_SECTION_MISSING

**a.** A required schema section is missing.
**b.** The required sections (corresponding to the schema, unit classes, unit modifiers, value classes,
schema attributes, and properties) are not in the correct order and hence not detected.
**b.** The required sections (corresponding to the prologue, schema, unit classes, unit modifiers, value classes,
schema attributes, properties and epilogue) are not in the correct order and hence not detected.

**Note:** Required schema sections may be empty, but still be given.

Expand All @@ -423,29 +432,23 @@ schema attributes, and properties) are not in the correct order and hence not de
**b.** A HED version specification does not have the correct syntax for the schema file format.
**c.** A HED schema version does not comply with semantic versioning.

### B.2.2. Invalid usage error

#### SCHEMA_DEPRECATED_INVALID

**a.** The value of a `deprecatedFrom` attribute does not correspond to a valid schema version.
**b.** An element with a `deprecatedFrom` attribute has a child node that does not have a `deprecatedFrom` attribute.

### B.2.3. Mediawiki format errors

#### WIKI_DELIMITERS_INVALID

**a.** Delimiters used in the wiki are invalid.
**b.** Schema line content after node name is not enclosed with `<nowiki></nowiki>` delimiters.
**c.** A line has unmatched or multiple `<nowiki></nowiki>`, `[ ]`, or `{ }` delimiters.
**d.** Attributes section of a node is malformed(eg hanging `=` character).

#### WIKI_LINE_START_INVALID

**a.** Start of body line not `'''` or `*`.

#### WIKI_SEPARATOR_INVALID

**a.** Required wiki section separator is missing or misplaced.
**b.** A required schema separator is missing. (The required separators are: `!# start schema`, `!# end schema`, and `!# end hed`.)
**a.** A malformed section separator is present
**b.** A duplicate section separator is present.

### B.2.4. XML format errors

Expand Down
3 changes: 1 addition & 2 deletions tests/hed_error_codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
],
"schema_validation_errors": [
"SCHEMA_ATTRIBUTE_INVALID",
"SCHEMA_ATTRIBUTE_VALUE_INVALID",
"SCHEMA_CHARACTER_INVALID",
"SCHEMA_DEFAULT_UNITS_INVALID",
"SCHEMA_DEPRECATED_INVALID",
"SCHEMA_DUPLICATE_NODE",
"SCHEMA_HEADER_INVALID",
"SCHEMA_LIBRARY_INVALID",
Expand Down
49 changes: 48 additions & 1 deletion tests/json_tests/SCHEMA_ATTRIBUTE_INVALID.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,65 @@
"fails": [
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {unknownAttribute=invalid}",
"'''Tag-with-unknown''' {unknownAttribute}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {unitAttribute}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes''' <nowiki>{unitProperty}</nowiki>",
"* unitAttribute <nowiki>{unitProperty}</nowiki>",
"'''Properties''' <nowiki></nowiki>",
"* unitProperty <nowiki></nowiki>",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag'''",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers''' <nowiki></nowiki>",
"* mod1 <nowiki>{unitAttribute}[Wrong attribute type]</nowiki>",
"'''Value classes'''",
"'''Schema attributes''' <nowiki>{unitProperty}</nowiki>",
"* unitAttribute <nowiki>{unitProperty}</nowiki>",
"'''Properties''' <nowiki></nowiki>",
"* unitProperty <nowiki></nowiki>",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {suggestedTag=Event}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID",
"name": "attribute-invalid-allowed-character",
"warning": true,
"description": "A schema unit has an invalid conversion factor",
"schema": "",
"definitions": [],
"tests": {
"schema_tests": {
"fails": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=?d}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=?, allowedCharacter=letters}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=letters}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
]
}
}
}
]
136 changes: 136 additions & 0 deletions tests/json_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_CONVERSION_FACTOR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
[
{
"error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID",
"name": "attribute-conversion-factor-invalid",
"warning": true,
"description": "A schema unit has an invalid conversion factor",
"schema": "",
"definitions": [],
"tests": {
"schema_tests": {
"fails": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass ",
"** testUnit1{SIUnit, conversionFactor=-1.0}",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass ",
"** testUnit1{SIUnit, conversionFactor=word}",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass ",
"** testUnit1{SIUnit, conversionFactor=None}",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass ",
"** testUnit1{SIUnit, conversionFactor}",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass {defaultUnits=testUnit1}",
"** testUnit1",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
]
}
}
},
{
"error_code": "WIKI_DELIMITERS_INVALID",
"name": "attribute-conversion-format",
"warning": true,
"description": "A schema unit has an invalid conversion factor due to bad formatting",
"schema": "",
"definitions": [],
"tests": {
"schema_tests": {
"fails": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"* testUnitClass ",
"** testUnit1{SIUnit, conversionFactor=}",
"** testUnit2",
"** testUnit3",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
]
}
}
}
]
Loading