Commas in DocumentFormat.OpenXml.Wordprocessing.Name.Val property cause invalid value error
- Dominant language
- C#
- Stars
- 4.6k
- Forks
- 605
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
According to the "data\SchematronFiles\word.xml" lines 3618 - 3628 the `w:val` property for the `w:name` element should be invalid if it contains a comma only for `w:name` elements that are children of `w:category` or `w:fieldMapData`, but the `CollectSchematronItems` method from "tools\SemanticConstraintRegGen\SchematronDataProvider.cs" line 66 splits the `Context` on `/` leaving only the property name instead of the full path. So, in schematron.json the restriction becomes:
```json
{
"Context": "w:name",
"Test": "matches(@w:val, \u0022[^,]*\u0022)",
"App": "Word"
},
```
restricting the `w:name` property from containing commas for all elements in Word.
This may be a "won't fix", because it looks like it will either be a major rewrite of how that validation works that could involve breaking changes or creating separate classes for the different `w:name` elements, like `FieldMapDataName` and `CategoryName`, but this would definitely be a breaking change as they all currently use `DocumentFormat.OpenXml.Wordprocessing.Name` for this class. I'm adding the issue in the hope I'm wrong.
**To Reproduce**
Add commas to the `w:val` property of a `w:name` element that is not the child of `w:fieldMapData` or `w:category` (e.g. `w:docPartPr` or `w:style`) then create an instance of the `OpenXmlValidator` and validate the file.
**Observed behavior**
The validator returns an invalid value error for the `w:val` property.
**Expected behavior**
Expected the validation to pass without error.
**Desktop (please complete the following information):**
- OS: Windows 11
- Office version 16.0.16626.20086
- .NET Target: .Net 8
- DocumentFormat.OpenXml Version: 3.0.1
**Additional context**
This was discovered from a user issue with the ooxml-validator-vscode: https://github.com/mikeebowen/ooxml-validator-vscode/issues/25.
Contributor guide
Assessment
This issue has not been assessed yet.