[英]Accept Insertion and reject deletion openxml
I need to compare two Word files and merge all insertions into a third one.我需要比较两个 Word 文件并将所有插入内容合并到第三个文件中。 I have managed to do that with OpenXML-Power-Tools and WmlCompare, but how do I reject only deletions?
我已设法使用 OpenXML-Power-Tools 和 WmlCompare 做到这一点,但我如何才能拒绝删除?
Accepting insertions is easy with OpenXmlPowerTools.RevisionAccepter
but I can't get the rejection of deletions to work, that way I would get merged file without revisions.使用
OpenXmlPowerTools.RevisionAccepter
接受插入很容易,但我无法拒绝删除工作,这样我就可以在没有修改的情况下获得合并文件。
Should I take this approach or would you suggest different approach?我应该采用这种方法还是你会建议不同的方法?
Rules are:规则是:
It is relatively easy to reject, or undo, deletions.拒绝或撤消删除相对容易。 So, say you have the following sample paragraph with one
w:del
element that wraps a deleted w:r
element.因此,假设您有以下示例段落,其中一个
w:del
元素包装了一个已删除的w:r
元素。
<w:p>
<w:r>
<w:t xml:space="preserve">This is </w:t>
</w:r>
<w:del w:id="0" w:author="Thomas Barnekow" w:date="2020-02-16T14:37:00Z">
<w:r>
<w:delText xml:space="preserve">deleted </w:delText>
</w:r>
</w:del>
<w:r>
<w:t>text.</w:t>
</w:r>
</w:p>
To reject the deletion, you need to unwrap the deleted w:r
and turn the w:delText
into a w:t
again.要拒绝删除,您需要将已删除的
w:r
解包并将w:delText
再次变成w:t
。 Without any further processing (see below), the result of your rejecting the deletion would look like this:如果不进行任何进一步处理(见下文),您拒绝删除的结果将如下所示:
<w:p>
<w:r>
<w:t xml:space="preserve">This is </w:t>
</w:r>
<w:r>
<w:t xml:space="preserve">deleted </w:delText>
</w:r>
<w:r>
<w:t>text.</w:t>
</w:r>
</w:p>
As an optional step, using the MarkupSimplifier
of the Open XML PowerTools, you could also coalesce adjacent runs having identical formatting, which would result in the following markup:作为可选步骤,使用 Open
MarkupSimplifier
PowerTools 的 MarkupSimplifier,您还可以合并具有相同格式的相邻运行,这将导致以下标记:
<w:p>
<w:r>
<w:t>This is deleted text.</w:t>
</w:r>
</w:p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.