AbstractNum和NumberingInstance的用途 [英] Purpose of AbstractNum and NumberingInstance
问题描述
1)
我当时想他的目的AbstractNum
是重用编号格式,而NumberingInstance
是创建新列表(从1重新开始).但是我注意到的是,如果在列表1处重新启动列表的第二个实例,则openxml文档将具有AbstractNum
元素的精确副本(唯一的区别是Nsid
)和指向该AbstractNum
的NumberingInstance
元素.
I was thinking purpose of he AbstractNum
is to reuse the numbering format and NumberingInstance
is to create new list (restart at 1). But what I've noticed is if restart the second instance of the list at 1, openxml document will have a exact copy of the AbstractNum
element (only difference is Nsid
) and a NumberingInstance
pointing to that AbstractNum
element.
例如: 如果我有以下列表
ex: If I have a list as follows
- 第1项
- 第2项
和以下具有完全相同样式的其他列表,但从1重新开始
and another list as below with exact same styling but restart at 1
- 第3项
- 第4项
这将产生两个副本AbstractNum
(具有相同的定义)和两个副本NumberingInstance
.如果样式相同,具有重复定义(AbstractNum
)的目的是什么
This will produce two copies of AbstractNum
(with same definition) and two copies of NumberingInstance
. What is the purpose of having duplicate definition (AbstractNum
) if the styling is the same
2)
如果需要为每个NumberingInstance
创建重复的AbstractNum
,有人可以告诉我如何生成Nsid
值(十六进制).看起来如果您有两个具有相同Nsid
的AbstractNum
也会导致列表编号的延续(而不是第二个列表从1开始),但是我不知道如何生成唯一的Nsid
>
If need to create duplicate AbstractNum
for each NumberingInstance
, can someone tell me how to generate the Nsid
value (hex). it looks like if you have two AbstractNum
with same Nsid
will also causing the continuation of list numbering (instead of start at 1 for the second list) But I don't know how to generate a unique Nsid
推荐答案
对于问题的第一部分,重要的是要了解您有时可以使用不同的Open XML标记来达到相同的效果.只要Microsoft Word以某种方式生成标记并不表示您的方式不正确,只要您的方式符合标准即可.
Regarding the first part of your question, it is important to understand that you can sometimes use different Open XML markup to achieve the same effect. Just because Microsoft Word produces markup in a certain way does not mean your way is incorrect, as long as your way is compliant with the standard.
为增强我的原始答案,以下示例说明了如何使用问题中提供的大致文字来重新编号而不重复w:abstractNum
元素:
Enhancing my original answer, here's an example of how you would restart numbering without duplicating the w:abstractNum
element, using roughly the text provided in the question:
Unnumbered text before first list.
1. Item 1
2. Item 2
Unnumbered text before second list.
1. Item 3 (restarted)
2. Item 4
让我们看一下相应的主文档部分(document.xml
),注意我已经简化了Microsoft Word创建的标记:
Let's look at the corresponding main document part (document.xml
), noting that I've simplified the markup created by Microsoft Word:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:r>
<w:t>Unnumbered text before first list.</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 1</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 2</w:t>
</w:r>
</w:p>
<w:p>
<w:r>
<w:t>Unnumbered text before second list.</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="2"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 3 (restarted)</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph"/>
<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="2"/>
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item 4</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
您会注意到,这两个列表在其w:numId
元素中引用了两个编号id(1和2).
You will note that the two lists are referencing two numbering ids (1 and 2) in their w:numId
elements.
接下来,这是相应的编号定义部分(numbering.xml
):
Next, here is the corresponding numbering definitions part (numbering.xml
):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="w15">
<!-- This is the only w:abstractNum element in numbering.xml -->
<w:abstractNum w:abstractNumId="0" w15:restartNumberingAfterBreak="0">
<w:nsid w:val="23B5103A"/>
<w:multiLevelType w:val="hybridMultilevel"/>
<w:tmpl w:val="40963B22"/>
<!-- The following w:lvl is referenced by w:ilvl with w:val="0" -->
<w:lvl w:ilvl="0" w:tplc="0409000F">
<w:start w:val="1"/>
<w:numFmt w:val="decimal"/>
<w:lvlText w:val="%1."/>
<w:lvlJc w:val="left"/>
<w:pPr>
<w:ind w:left="720" w:hanging="360"/>
</w:pPr>
</w:lvl>
<!-- Markup for numbering levels 1-7 removed -->
<w:lvl w:ilvl="8" w:tplc="0409001B" w:tentative="1">
<!-- Child elements removed -->
</w:lvl>
</w:abstractNum>
<!-- The following w:num is referenced by the w:numId with w:val="1" -->
<w:num w:numId="1">
<w:abstractNumId w:val="0"/>
</w:num>
<!-- The following w:num is referenced by the w:numId with w:val="2" -->
<w:num w:numId="2">
<w:abstractNumId w:val="0"/>
<!-- The w:lvlOverride with its w:startOverride child restarts numbering -->
<w:lvlOverride w:ilvl="0">
<w:startOverride w:val="1"/>
</w:lvlOverride>
<!-- You can also override levels 1 to 8 in the same way, if required -->
</w:num>
</w:numbering>
您会看到它只使用一个由两个`w:num'元素引用的w:abstractNum
,其中一个元素会通过重新开始编号来覆盖至少一个级别.
You can see that this uses only one w:abstractNum
that is referenced by two `w:num' elements, one of which overrides the at least one level by restarting the numbering.
关于问题的第二部分,如果要模仿Microsoft Word的行为,w:nsid
元素(抽象编号定义标识符)的值就是一个唯一的数字,表示为长十六进制数.该标准没有说明应如何精确地创建它.因此,例如,您可以接受任何w:abstractNum
元素尚未使用的数字.
Regarding the second part of your question, if you want to mimic the behavior of Microsoft Word, the value of the w:nsid
element (Abstract Numbering Definition Identifier) is simply a unique number stated as a long hex number. The standard is silent about how exactly it should be created. So, for example, you can take pretty much any number that is not yet used by any w:abstractNum
element.
这篇关于AbstractNum和NumberingInstance的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!