Open-XML-SDK icon indicating copy to clipboard operation
Open-XML-SDK copied to clipboard

Validation error - Unexpected element 'BiDi' in WordprocessingDocument

Open Xiphereal opened this issue 4 years ago • 3 comments

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:

unnamed

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:

unnamed

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.

Xiphereal avatar Dec 23 '20 18:12 Xiphereal

We have the same problem.

Suriman avatar Dec 28 '20 07:12 Suriman

Any news?

carzaza avatar Feb 10 '21 10:02 carzaza

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:

image

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

image

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

Muppets avatar Mar 07 '21 16:03 Muppets