docx/core-properties-title

The document's OPC core-properties part carries a Dublin Core title element.

Library verdicts: python-docx: — docxjs: —

Metadata

Feature iddocx/core-properties-title
Formatdocx
Categorymetadata
Spececma-376-5-part-2 § 11.1 dc:title

XPath assertions

ID / partPredicateXPathpython-docxdocxjs
core-properties-title-present
docProps/core.xml
exist
The core-properties part must carry a <dc:title> element.
//dc:title
core-properties-title-value
docProps/core.xml
equal = Test Title
The <dc:title> element must hold the literal string 'Test Title'.
//dc:title

Render assertions

No render assertions declared.

Generator source

scripts/gen_core_properties_title.py

#!/usr/bin/env python3
"""Generate ``fixtures/docx/core-properties-title.docx``.

A minimal document exercising the OPC core-properties ``dc:title`` element.
The document content itself is irrelevant; the feature under test is the
metadata carried in ``docProps/core.xml``. Designed to satisfy the assertions
in ``features/docx/core-properties-title.json``.
"""

from __future__ import annotations

from pathlib import Path

from docx import Document

_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "docx" / "core-properties-title.docx"


def main() -> int:
    doc = Document()
    doc.core_properties.title = "Test Title"
    doc.add_paragraph("Body content; metadata is the feature under test.")
    _OUT.parent.mkdir(parents=True, exist_ok=True)
    doc.save(_OUT, reproducible=True)
    print(_OUT)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "docx/core-properties-title",
  "title": "Core-properties title",
  "format": "docx",
  "category": "metadata",
  "summary": "The document's OPC core-properties part carries a Dublin Core title element.",
  "spec": {
    "source": "ecma-376-5-part-2",
    "clause": "11.1",
    "element": "dc:title",
    "notes": "ECMA-376 Part 2 (OPC) defines the core-properties part at 'docProps/core.xml' with namespace bindings for Dublin Core (dc), Dublin Core Terms (dcterms), and OPC core-properties (cp). The title element lives in the dc namespace. This is a package-level feature — the content of word/document.xml is irrelevant; the assertion targets the metadata part."
  },
  "fixtures": {
    "machine": "docx/core-properties-title",
    "office": "docx/core-properties-title"
  },
  "generator": {
    "python": "scripts/gen_core_properties_title.py"
  },
  "assertions": [
    {
      "id": "core-properties-title-present",
      "part": "docProps/core.xml",
      "namespaces": {
        "cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
        "dc": "http://purl.org/dc/elements/1.1/"
      },
      "xpath": "//dc:title",
      "must": "exist",
      "description": "The core-properties part must carry a <dc:title> element."
    },
    {
      "id": "core-properties-title-value",
      "part": "docProps/core.xml",
      "namespaces": {
        "cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
        "dc": "http://purl.org/dc/elements/1.1/"
      },
      "xpath": "//dc:title",
      "must": "equal",
      "value": "Test Title",
      "description": "The <dc:title> element must hold the literal string 'Test Title'."
    }
  ]
}

Fixture

Download core-properties-title.docx (18.6 KB)

Reference preview

Reference (machine, page 1 PNG)

docx/core-properties-title page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec notes

ECMA-376 Part 2 (OPC) defines the core-properties part at 'docProps/core.xml' with namespace bindings for Dublin Core (dc), Dublin Core Terms (dcterms), and OPC core-properties (cp). The title element lives in the dc namespace. This is a package-level feature — the content of word/document.xml is irrelevant; the assertion targets the metadata part.