Open-XML-SDK
Open-XML-SDK copied to clipboard
Validation error - Unexpected element 'BiDi' in WordprocessingDocument
Is this a:
- [x] Issue with the OpenXml library
- [ ] Question on library usage
Description
I'm having an issue with relation to the OpenXmlValidator.Validate() method and a BiDi element in the style.xml in WordprocessingDocument. The thing is that i'm currently working with the DevExpress RichTextEditor Control for WPF for creating and editing DOCX documents . When saving any document with that control, the generated style.xml is as follows:

As you can see, a default style for a paragraph is defined with the Xpath: styles[1]/docDefaults[1]/pPrDefault[1]/pPr[1]. Right there, lives a bidi element with value "0". If we try to validate that document with the OpenXmlValidator.Validate() method, we'll get a validation error as follows:

I don't quite understant why is it saying that there is an error with an unexpected child element bidi, given that if i'm not wrong, a bidi element inside a pPr element is totaly valid: https://docs.microsoft.com/es-es/dotnet/api/documentformat.openxml.wordprocessing.bidi?view=openxml-2.8.1
Information
- .NET Target: Core 3.1 WPF
- DocumentFormat.OpenXml Version: 2.11.3, but encountered in 2.7.2 and also occurs in 2.12
Repro OpenXmlSdkBidiValidationError.zip
Observed
The OpenXmlValidator.Validate() method arise a "The element has unexpected child element 'http://…2006/main:bidi'." validation error.
Expected Given that the document schema is correct, no validation errors should arise.
We have the same problem.
Any news?
This validation failure is actually down to the fact bidi element is being generated in the wrong place in the XML.
w:Pr node in the ECMA standard is defined as a Sequence and so the order is mandatory on the children:

Moving bidi element to before spacing makes it match the specifications and it now passes the validation:

I would probably raise this as a bug with the DevExpress team.