当前位置:网站首页>How to describe multiple paragraphs with different font settings in Open Office XML format

How to describe multiple paragraphs with different font settings in Open Office XML format

2022-08-10 13:20:00 Wang Zixi

_rels.rels

This defines tell MS Word Where to find references to document content. In the following cases,它引用 word/document.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
   <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
</Relationships>

_RELS/DOCUMENT.XML.RELS

This file defines resources that are embedded in the document content(例如图像)的引用. If our simple document has no embedded resources,Then the relationship label is empty:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
</Relationships>

[CONTENT_TYPES].XML

[Content_Types].xml Contains information about media types within the document. Because we only have text content,所以很简单:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
   <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
   <Default Extension="xml" ContentType="application/xml"/>
   <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
</Types>

DOCUMENT.XML

This is the main one that contains the text content of the document XML. 在该文件中,Developers will find that some namespace references in the documentation are unused,但请注意,We should not delete them,因为 MS Word 需要它们.

Here is our simplified example:

<w:document>
   <w:body>
       <w:p w:rsidR="005F670F" w:rsidRDefault="005F79F5">
           <w:r><w:t>Test</w:t></w:r>
       </w:p>
       <w:sectPr w:rsidR="005F670F">
           <w:pgSz w:w="12240" w:h="15840"/>
           <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
           <w:cols w:space="720"/>
           <w:docGrid w:linePitch="360"/>
       </w:sectPr>
   </w:body>
</w:document>

主节点<w:document> represents the document itself,<w:body> 包含段落,嵌套在<w:body> in is by<w:sectPr> Defined page size.

<w:rsidR> is an ignorable property; 它被 MS Word 内部使用.

Let's look at a more complex document with three paragraphs. 我在 Microsoft Word is highlighted with the same color in the screenshot of XML,So we can see the correlation:

Word text in the document,Labels are paired w:t 包裹.字体通过 w:rFont 标签指定.

颜色通过 w:color 指定.

新的段落,通过 w:p 指定.w:p 里,仍然是 w:t.

Paragraph Structure

A simple document consists of paragraphs,A paragraph consists of a series(A series hassame font、color, etc. text)组成,A chain consists of characters(例如 <w:t>)组成.<w:t> There may be several characters inside the tag,在同一个 run There may be several characters in the structure.

TEXT PROPERTIES

The basic text attribute is the font、大小、颜色、样式等. 大约有 40 tags are used to specify the text appearance. As seen in our three paragraph example,每行在 <w:rPr> has its own properties,指定 <w:color><w:rFonts> 和粗体 <w:b>.

需要注意的重要一点是,The attribute distinguishes between two sets of characters,Normal scripts and complex scripts(例如阿拉伯语),And the properties have different tags,It depends on the type of characters it affects.

Most normal script attribute tags have a matching complex script tag,并添加了一个 C,Specifies that this property is used for复杂脚本. 例如:<w:i>(斜体)变为 <w:iCs>,Bold labels for normal scripts <w:b> into a complex script <w:bCs>.

原网站

版权声明
本文为[Wang Zixi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208101223353767.html