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

OpenXmlValidator.Validate() returns error for valid presentation

Open ashahabov opened this issue 3 years ago • 10 comments

Description

OpenXmlValidator.Validate() finds errors in valid presentation.

When I say valid presentation, I mean PowerPoint app doesn't complain.

Repro

test.pptx

var pres = PresentationDocument.Open("test.pptx", false);
var validator = new OpenXmlValidator(FileFormatVersions.Microsoft365);

var errors = validator.Validate(pres);

foreach (var error in errors)
{
    Console.WriteLine(error.Description);
}
pres.Close();

The element has unexpected child element 'http://schemas.openxmlformats.org/drawingml/2006/chart:showDLblsOverMax'. The 'uri' attribute is not declared. The element has invalid child element 'http://schemas.microsoft.com/office/drawing/2017/03/chart:dataDisplayOptions16'. List of possible elements expected: <http://schemas.microsoft.com/office/drawing/2017/03/chart:dispNaAsB lank>.

Observed behavior errors collection is not empty.

Expected behavior errors should be empty.

Desktop

  • OS: Windows
  • Office version: Microsoft 365 MSO (Version 2202 Build 16.0.14931.20718) 32-bit
  • .NET Target: .NET 6
  • DocumentFormat.OpenXml Version: 2.18.0

ashahabov avatar Oct 24 '22 15:10 ashahabov

I looked into this some and there is definitely, something incorrect happening here. The validator is just not seeing the data correctly; showDLblsOverMax does not have any children, the ext element has a URI attribute, and the dataDisplayOptions16 element's only child is dispNaAsBlank, so I'm not sure what's going on here. This will take some investigation.

Do you see this with any other files? How was this file created? PowerPoint, the SDK, etc.

mikeebowen avatar Oct 25 '22 18:10 mikeebowen

test.pptx is not my file, hence cannot say exactly what tool created/edited this. But now I've created a new other test-2.pptx presentation via PowerPoint app. The validator generates issues also for this.

ashahabov avatar Oct 26 '22 05:10 ashahabov

This issue is still going strong. We are seeing these validation errors with multiple different files (pptx and xlsx)

I will not only attach a file that has this behaviour but also try to describe minimal reproduction steps: singlechart.pptx singlechart_new_from_scratch.pptx singlechart_new_from_scratch_v2.pptx

Reproduction

Open Powerpoint 365 Select New Blank Presentation Select All -> Delete Insert -> Chart "Clustered Column" (the default) Leave the data unchanged Select a Column -> Right click and in context menu "Add Data Labels" When the data labels are shown -> "Format Data Labels" Select Label Position "Center"

Save the file Close the file

Run validation on the file: File is invalid (Schema error for unexpected child of Chart: ShowDataLabelsOverMaximum)

I used 2 different versions of Open XML SDK to validate: DocumentFormat.OpenXml.dll 2.5.5631.0 image

DocumentFormat.OpenXml.Framework.dll 3.0.0.0 image

p-erk avatar Nov 17 '23 11:11 p-erk

@mikeebowen maybe one thing of note: between 2.5 and 3.0 the validation for URI and dataDisplayOptions16 changed

The same document i posted earlier validated in v2.5 vs v3.0

26 errors in v2.5: The element has unexpected child element 'http://schemas.openxmlformats.org/drawingml/2006/chart:showDLblsOverMax'. The element has unexpected child element 'http://schemas.microsoft.com/office/drawing/2012/chart:leaderLines'. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared. The 'smtClean' attribute is not declared.

4 errors in v3: The element has unexpected child element 'http://schemas.openxmlformats.org/drawingml/2006/chart:showDLblsOverMax'. The 'uri' attribute is not declared. The element has invalid child element 'http://schemas.microsoft.com/office/drawing/2017/03/chart:dataDisplayOptions16'. List of possible elements expected: http://schemas.microsoft.com/office/drawing/2017/03/chart:dispNaAsBlank. The element has unexpected child element 'http://schemas.microsoft.com/office/drawing/2012/chart:leaderLines'.

the smart tags you see in 2.5 was fixed in v 2.12 but why there are 2 new errors in v3 even though the xml is valid according to the schema, i do not quite understand, but that might be a good place to start looking

p-erk avatar Nov 17 '23 13:11 p-erk