如何在 Libre Office 平面 XML (fods) 文件中将字符串标记为粗体? [英] How is a String marked as bold in a Libre Office flat XML (fods) file?

查看:27
本文介绍了如何在 Libre Office 平面 XML (fods) 文件中将字符串标记为粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看来自 <代码>.fods 文件:

  <table:table-column table:style-name="co1" table:default-cell-style-name="ce17"/>
  <table:table-row table:style-name="ro1">
    <table:table-cell table:style-name="ce15" office:value-type="string" calcext:value-type="string">
      <text:p>John Smith</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row table:style-name="ro2">
    <table:table-cell table:style-name="ce16" office:value-type="string" calcext:value-type="string">
      <text:p>(123) 456-7890</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row table:style-name="ro2">
    <table:table-cell office:value-type="string" calcext:value-type="string">
      <text:p>123 Main Street</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row table:style-name="ro2">
    <table:table-cell office:value-type="string" calcext:value-type="string">
      <text:p>Anywhere, ZZ 12345-6789</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row table:style-name="ro1">
    <table:table-cell table:style-name="ce15" office:value-type="string" calcext:value-type="string">
      <text:p>Jane Doe</text:p>
    </table:table-cell>
  </table:table-row>
  <table:table-row table:style-name="ro2">
    <table:table-cell table:style-name="ce16" office:value-type="string" calcext:value-type="string">
      <text:p>(234) 567-8901</text:p>

Libre Office 中打开时,名称以粗体显示.这会在上面的 XML 中体现在哪里?我只看到一个没有粗体、下划线等标记的 value-type="string".

When opened in Libre Office the names are in bold. Where would that be reflected in the above XML? I'm only seeing a value-type="string" with no markup for bold, underline, etc.

所有内容都在一个列中,因此不太确定 default-cell-style-name="ce17" 属性表示什么.

Everything is in a single column, so not quite sure what the default-cell-style-name="ce17" attribute indicates.

虽然数据源自 .doc 文件,但我在文件上使用 Libre Office.

While the data originated as a .doc file, I'm using Libre Office on the file.

我希望从 XML 中提取名称,这些名称实际上与电话或地址的区别在于它们以粗体显示.我想也没有数字,但我想从电子表格中选择粗体数据.

I'm looking to extract the names from the XML, which are only, really, distinguished from phone or address in that they're in bold. I suppose there's no numeric numbers, either, but I'd like to select the bold data from the spreadsheet.

格式化信息似乎有些模糊:

格式化

样式和格式控件有很多,提供了许多控制信息的显示.

The style and formatting controls are numerous, providing a number of controls over the display of information.

页面布局由多种属性控制.这些包括页面大小、数字格式、纸盒、打印方向、页边距、边框(及其线宽)、填充、阴影、背景、列、打印页序、首页页码、比例、表格居中、最大值脚注高度和分隔符,以及许多布局网格属性.

Page layout is controlled by a variety of attributes. These include page size, number format, paper tray, print orientation, margins, border (and its line width), padding, shadow, background, columns, print page order, first page number, scale, table centering, maximum footnote height and separator, and many layout grid properties.

页眉和页脚可以定义固定和最小高度,边距、边框线宽、填充、背景、阴影和动态间距.

Headers and footer can have defined fixed and minimum heights, margins, border line width, padding, background, shadow, and dynamic spacing.

特定文本、段落、ruby 文本有很多属性,部分、表格、列、列表和填充.具体字符可以有它们的字体、大小、通用字体系列名称(罗马 - 衬线、瑞士 - 无衬线,现代 - 等宽,装饰,脚本或系统),和其他属性设置.段落可以有它们的垂直空间通过keep together、widow和orphan的属性控制,以及具有其他属性,例如首字下沉"以提供特殊的格式化.清单非常广泛;见参考文献(在具体以实际标准为准)了解详情.

There are many attributes for specific text, paragraphs, ruby text, sections, tables, columns, lists, and fills. Specific characters can have their fonts, sizes, generic font family names (roman – serif, swiss – sans-serif, modern – monospace, decorative, script or system), and other properties set. Paragraphs can have their vertical space controlled through attributes on keep together, widow, and orphan, and have other attributes such as "drop caps" to provide special formatting. The list is extremely extensive; see the references (in particular the actual standard) for details.

推荐答案

值和格式放在 XML 文件的不同部分.

Values and formats are placed in different sections of the XML file.

通常,您有一个样式"部分,其中所有格式都使用名称(样式:名称)定义.

So usually, you have a 'style' section where all the formats are defined with a name (style:name).

在表格部分,您定义了表格、放置在其中的值以及样式(由他的表格:样式名称"标识).您可以为每个单元格、整行、整列甚至整个表格定义样式.

In the table section, you have the table defined, the values placed in it and which style has (identified by his 'table:style-name'). You can define a style for each cell, for an entire row, entire column or even the entire table.

因此,在您的情况下,您可以识别正在使用的样式名称的粗体文本.这并不总是那么容易,因为您可以为整个列/行 (default-cell-style-name="ce17") 指定默认样式,以防样式未定义.

So in your case, you can identify the bold text looking to the style name is using. That's not always easy, because you can specify a default style for an entire column/row (default-cell-style-name="ce17") which it would takes place in case the style is not defined.

我开发了一个用于在 Java 中解析 ODS 文件的库,所以如果您需要灵感,可以在 Github 中查看:https://github.com/miachm/SODS

I developed a library for parse ODS Files in Java, so in case you need inspiration you can check it out in Github: https://github.com/miachm/SODS

这篇关于如何在 Libre Office 平面 XML (fods) 文件中将字符串标记为粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆