文档模型的示例

必须为您打算创建索引的每种文档格式定义一种文档模型。以下是纯文本结构化文档的简单文档模型。注意,该示例中的 GPP 代表“通用解析器”。

<?xml version="1.0"?>
<GPPModel>                  - here begins the GPP document model

  <GPPFieldDefinition       - here begins a field definition
  name="Head"               - the name you assign to this field
   start="[head]"           - the boundary string at the beginning of the field
  end="[/head]"             - the boundary string at the end of the field
 exclude="YES" />

  <GPPFieldDefinition       - here begins the next field definition
  name="Abstract"
  start="[abstract]"
  end="[/abstract]"
  exclude="NO" />
:
:
</GPPModel>                             

档模型在 XML 语言中是使用附录G. 文档模型参考中定义的标记指定的。文档模型由文本字段定义和属性定义组成。此示例说明在 GPPFieldDefinition 元素中只定义了文本字段定义。 类似地,可以使用 GPPAttributeDefinition 来定义文档属性。

该示例中的第一行 <?xml version="1.0"?> 指定文档模型是使用 XML 标记来编写的。每个文本字段定义都指定边界字符串以标识源文档中的字段定义的 startend。 因此,每当文档包含后跟一些文本的字符序列 [head],然后接着是字符序列 [/head], 就会将这些边界字符串之间的文本作为由名称 head 指定的文本字段的内容。

对每个字段定义指定字段名。查询可通过使用此字段名来将搜索限制为某个文本字段的内容。该名称可以是固定的,也可以是按照规则从结构单元的内容中派生的。例如,这样一个名称可以是 XML 实体的标记名或者是 XML 属性的名称。