核心文档属性

openxml格式为每个文档提供了一组要维护的描述性属性。其中之一是 核心文件属性 . 核心属性是所有openxml格式的通用属性,并出现在文档、演示文稿和电子表格文件中。核心文档属性中的“Core”是指 Dublin Core ,一个元数据标准,它定义了一组用于描述资源的核心元素。

芯特性在ISO/IEC 29500规范第2部分第11节中进行了说明。中某些核心属性的名称 python-docx 与规范中的更改一致,以符合MS API。

其他属性(如公司名称)是自定义属性,保存在 app.xml .

候选方案

>>> document = Document()
>>> core_properties = document.core_properties
>>> core_properties.author
'python-docx'
>>> core_properties.author = 'Brian'
>>> core_properties.author
'Brian'

属性

支持15个属性。所有unicode值限制为255个字符(不是字节)。

作者 (unicode)

注:在规范中命名为'creator'。主要负责制作资源内容的实体。(都柏林核心区)

类别 (unicode)

此包内容的分类。此属性的示例值可能包括:简历、信函、财务预测、建议、技术演示等。(开放包装公约)

评论 (unicode)

注:在规范中命名为“description”。对资源内容的解释。值可能包括摘要、目录、对内容的图形表示的引用以及内容的自由文本帐户。(都柏林核心区)

content_status (unicode)

内容的状态。值可能包括“草稿”、“审阅”和“最终”。(开放包装公约)

创建 (日期时间)

资源的创建日期。(都柏林核心区)

标识符 (unicode)

在给定上下文中对资源的明确引用。(都柏林核心区)

关键词 (unicode)

支持搜索和索引的分隔关键字集。这通常是属性中其他位置不可用的术语列表。(开放包装公约)

语言 (unicode)

资源的智力内容的语言。(都柏林核心区)

last_modified_by (unicode)

执行最后修改的用户。标识是特定于环境的。示例包括姓名、电子邮件地址或员工ID。建议此值尽可能简洁。(开放包装公约)

last_printed (日期时间)

上次打印的日期和时间。(开放包装公约)

被改进的 (日期时间)

更改资源的日期。(都柏林核心区)

修订 (国际)

修订号。此值可能指示保存或修订的数量,前提是应用程序在每次修订后都会对其进行更新。(开放包装公约)

主题 (unicode)

资源内容的主题。(都柏林核心区)

标题 (unicode)

为资源指定的名称。(都柏林核心区)

版本 (unicode)

版本指示符。此值由用户或应用程序设置。(开放包装公约)

XML样本

核心.xml由Microsoft Word制作:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties
    xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:dcmitype="http://purl.org/dc/dcmitype/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <dc:title>Core Document Properties Exploration</dc:title>
  <dc:subject>PowerPoint core document properties</dc:subject>
  <dc:creator>Steve Canny</dc:creator>
  <cp:keywords>powerpoint; open xml; dublin core; microsoft office</cp:keywords>
  <dc:description>
    One thing I'd like to discover is just how line wrapping is handled
    in the comments. This paragraph is all on a single
    line._x000d__x000d_This is a second paragraph separated from the
    first by two line feeds.
  </dc:description>
  <cp:lastModifiedBy>Steve Canny</cp:lastModifiedBy>
  <cp:revision>2</cp:revision>
  <dcterms:created xsi:type="dcterms:W3CDTF">2013-04-06T06:03:36Z</dcterms:created>
  <dcterms:modified xsi:type="dcterms:W3CDTF">2013-06-15T06:09:18Z</dcterms:modified>
  <cp:category>analysis</cp:category>
</cp:coreProperties>

架构摘要

<xs:schema
  targetNamespace="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
  xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:dcterms="http://purl.org/dc/terms/"
  elementFormDefault="qualified"
  blockDefault="#all">

  <xs:import
    namespace="http://purl.org/dc/elements/1.1/"
    schemaLocation="http://dublincore.org/schemas/xmls/qdc/2003/04/02/dc.xsd"/>
  <xs:import
    namespace="http://purl.org/dc/terms/"
    schemaLocation="http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd"/>
  <xs:import
    id="xml"
    namespace="http://www.w3.org/XML/1998/namespace"/>

  <xs:element name="coreProperties" type="CT_CoreProperties"/>

  <xs:complexType name="CT_CoreProperties">
    <xs:all>
      <xs:element name="category"        type="xs:string"   minOccurs="0"/>
      <xs:element name="contentStatus"   type="xs:string"   minOccurs="0"/>
      <xs:element ref="dcterms:created"                     minOccurs="0"/>
      <xs:element ref="dc:creator"                          minOccurs="0"/>
      <xs:element ref="dc:description"                      minOccurs="0"/>
      <xs:element ref="dc:identifier"                       minOccurs="0"/>
      <xs:element name="keywords"        type="CT_Keywords" minOccurs="0"/>
      <xs:element ref="dc:language"                         minOccurs="0"/>
      <xs:element name="lastModifiedBy"  type="xs:string"   minOccurs="0"/>
      <xs:element name="lastPrinted"     type="xs:dateTime" minOccurs="0"/>
      <xs:element ref="dcterms:modified"                    minOccurs="0"/>
      <xs:element name="revision"        type="xs:string"   minOccurs="0"/>
      <xs:element ref="dc:subject"                          minOccurs="0"/>
      <xs:element ref="dc:title"                            minOccurs="0"/>
      <xs:element name="version"         type="xs:string"   minOccurs="0"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="CT_Keywords" mixed="true">
    <xs:sequence>
      <xs:element name="value" minOccurs="0" maxOccurs="unbounded" type="CT_Keyword"/>
    </xs:sequence>
    <xs:attribute ref="xml:lang" use="optional"/>
  </xs:complexType>

  <xs:complexType name="CT_Keyword">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute ref="xml:lang" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

</xs:schema>