The document's OPC core-properties part carries a Dublin Core title element.
Library verdicts: python-docx: — docxjs: —
| Feature id | docx/core-properties-title |
|---|---|
| Format | docx |
| Category | metadata |
| Spec | ecma-376-5-part-2 § 11.1 dc:title |
| ID / part | Predicate | XPath | python-docx | docxjs |
|---|---|---|---|---|
core-properties-title-presentdocProps/core.xml | existThe core-properties part must carry a <dc:title> element. | //dc:title | — | — |
core-properties-title-valuedocProps/core.xml | equal = Test TitleThe <dc:title> element must hold the literal string 'Test Title'. | //dc:title | — | — |
No render assertions declared.
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())
{
"$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'."
}
]
}
