This document is missing a relationship
Description This document is missing a relationship,say "数据包中不存在指定部件", how to skip error or provide callback function ? Please provide a simple description of the issue encountered.
Information
- .NET Target: (net461)
- DocumentFormat.OpenXml Version: (2.11.3)
Repro #858
// Please add a self-contained, minimum viable repro of the issue.
// If you require external resources, please provide a gist or GitHub repro
// An Xunit style test is preferred, but a console application would work too.
When I unzip the docx file, on the path " word_rels\document.xml.rels", I found "Target="../NULL"/"
Are there any where to skip error relationship or delete error relationship ?
I use RemoveMalformedHyperlinksRelationshipErrorHandler to solve, but It not work.

Observed
Please add your observed behavior here
Expected
Please add your expected behavior here. Skip error or fix document.
Or use code do like this:
https://docs.microsoft.com/en-us/office/troubleshoot/word/image-part-relationship-rld8-not-found-error-microsoft-word
one solution is use nuget packages and save as a new file. <package id="FreeSpire.Doc" version="7.11.0" targetFramework="net461" />
using Spire.Doc;
using System.IO;
using (Document document = new Document(filePath))
var newFilePath = "newfile.docx";
document.SaveToFile(newFilePath, FileFormat.Docx);
return newFilePath;
The new file becom

The error image is lose, but the docx can open by "WordprocessingDocument.Open".

Can you include a snippet of how you tried to use the RemoveMalformedHyperlinksRelationshipErrorHandler? Also, you're saying you used 2.11.3 but also tried the RemoveMalformedHyperlinksRelationshipErrorHandler? That infrastructure was introduced with 2.12.0
Oh, the question occur in Version: (2.11.3), but when I update to 2.12.1,use code
var openSettings = new OpenSettings()
{
RelationshipErrorHandlerFactory = p => new RemoveMalformedHyperlinksRelationshipErrorHandler(p)
};
using (WordprocessingDocument doc = WordprocessingDocument.Open(memoryStream, true, openSettings)){}
In this class ‘RemoveMalformedHyperlinksRelationshipErrorHandler‘, I can override and return a new uri to Ignore some mistakes by partUri or url.
The RemoveMalformedHyperlinksRelationshipErrorHandler from https://github.com/OfficeDev/Open-XML-SDK/blob/master/test/DocumentFormat.OpenXml.Tests/OpenXmlDomTest/DocumentOpenTests.cs
Yes, but I'm still confused as to what you are looking for. That RemoveMalformedHyperlinksRelationshipErrorHandler you're using is a test one, and by no means is it expected to be used as-is in production. It's more of an example.
It seems like you are asking for a way to handle cases like this with the RelationshipErrorHandler. That's valid, I'm just somewhat confused by what you are asking for here as things are spread across multiple comments and issues. I'd need that repro case that the issue template asks you to provide and a clear understanding of what you are trying to do.
I think the reason is that package ' System.IO.Packaging.Package'. I need to find a way to abandon the invalid part, not abandon the docx file. I need to render a docx document, but when I cannot open the document (use WordprocessingDocument.Open), I can do nothing. Show the effective parts as possible,so we know there is an error in the document, and can do something. In the scene, we open a document and show it on Web by HTML. Is there another way to open document what not use 'WordprocessingDocument.Open' ?
我认为可能是'System.IO.Packaging.Package'包的问题。 尽可能的打开文档忽略错误的部分,而不是打不开。用户上传一个word文档,然后在Web网站以HTML形式展示。有错误的地方忽略或者使用占位符替代,这样就可以指定文档哪里有问题,或者尝试修复文档。 或者有其他方式打开文档吗 ?
We can probably make the RelationshipErrorHandler handle this kind of thing, but it doesn't appear to out of the box.
I'm fairly busy right now and can't investigate the design of this. I'll have some time in about a month. In the meantime, feel free to propose an API and I'm happy to review it.
See https://github.com/OfficeDev/Open-XML-SDK/issues/247 https://github.com/dotnet/runtime/issues/26084 https://github.com/OfficeDev/Open-XML-SDK/issues/715
@wtujvk
Can it fix this?
See my Chinese blogs too.