xlsx/core-properties-full--category

Every Dublin Core and dcterms field exposed by docProps/core.xml, one field isolated per expanded case. Each case round-trips through python-xlsx's Workbook.properties API.

Library verdicts: python-xlsx: — xlsxjs: —

Metadata

Feature idxlsx/core-properties-full--category
Formatxlsx
Categorymetadata
Familyxlsx/core-properties-full
Axis valuesfield=category
Spececma-376-5-part-2 § 11.1

XPath assertions

ID / partPredicateXPathpython-xlsxxlsxjs
core-category-present
docProps/core.xml
exist
The category element must be present in docProps/core.xml.
//cp:category
core-category-value
docProps/core.xml
equal = Reports
The category element's text must equal the supplied value.
//cp:category

Render assertions

No render assertions declared.

Generator source

scripts/gen_core_properties_full_xlsx.py

#!/usr/bin/env python3
"""Generate ``fixtures/xlsx/core-properties-full--<field>.xlsx`` fixtures.

Parameterised generator: one call per field under test. Mirrors the docx and
pptx counterparts and satisfies ``features/xlsx/core-properties-full.json``.

Fixtures are byte-reproducible: ``zip_date_time`` pins the zip-member clock
and ``created`` / ``modified`` are pinned to fixed ISO-8601 values.
"""

from __future__ import annotations

import argparse
import datetime as _dt
from pathlib import Path

from xlsx import Workbook

_REPO_ROOT = Path(__file__).resolve().parent.parent
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)

_PINNED_CREATED = _dt.datetime(2026, 1, 1, 0, 0, 0)
_PINNED_MODIFIED = _dt.datetime(2026, 1, 2, 0, 0, 0)


def _apply(wb, field: str, value: str) -> None:
    props = wb.properties
    # Always pin so default-now() timestamps don't sneak back in.
    props.created = _PINNED_CREATED
    props.modified = _PINNED_MODIFIED
    # The python-xlsx default creator is "xlsx"; blank it unless this case
    # is setting creator explicitly. Leaving it non-empty confuses the
    # `must=equal` assertion on //dc:creator for the other cases.
    if field != "creator":
        props.creator = ""

    if field == "title":
        props.title = value
    elif field == "subject":
        props.subject = value
    elif field == "creator":
        props.creator = value
    elif field == "description":
        props.description = value
    elif field == "language":
        props.language = value
    elif field == "keywords":
        props.keywords = value
    elif field == "last-modified-by":
        props.lastModifiedBy = value
    elif field == "revision":
        props.revision = value
    elif field == "category":
        props.category = value
    elif field == "content-status":
        props.contentStatus = value
    elif field == "created":
        props.created = _dt.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")
    elif field == "modified":
        props.modified = _dt.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ")
    else:
        raise SystemExit(f"Unknown field id: {field!r}")


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("--field", required=True)
    parser.add_argument("--value", required=True)
    parser.add_argument(
        "--out",
        default=str(_REPO_ROOT / "fixtures" / "xlsx" / "core-properties-full.xlsx"),
    )
    args = parser.parse_args()

    out_path = Path(args.out)
    if not out_path.is_absolute():
        out_path = _REPO_ROOT / out_path

    wb = Workbook()
    _apply(wb, args.field, args.value)
    out_path.parent.mkdir(parents=True, exist_ok=True)
    wb.save(out_path, zip_date_time=_REPRODUCIBLE_DT)
    print(out_path)
    return 0


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

Manifest (expanded)

{
  "$schema": "../manifest.schema.json",
  "id": "xlsx/core-properties-full--category",
  "kind": "literal",
  "title": "Core properties (full DC + dcterms field set)",
  "format": "xlsx",
  "category": "metadata",
  "summary": "Every Dublin Core and dcterms field exposed by docProps/core.xml, one field isolated per expanded case. Each case round-trips through python-xlsx's Workbook.properties API.",
  "spec": {
    "source": "ecma-376-5-part-2",
    "clause": "11.1",
    "notes": "ECMA-376 Part 2 / ISO 29500-2 section 11 defines the OPC 'core-properties' part. It carries a mix of Dublin Core, dcterms, and MS-OPC-core elements. This manifest isolates each one in turn so each XPath assertion proves that particular field round-trips. dcterms:created / dcterms:modified are set to a fixed ISO-8601 UTC timestamp in the generator so the fixtures are byte-reproducible."
  },
  "fixtures": {
    "machine": "xlsx/core-properties-full--category"
  },
  "generator": {
    "python": "scripts/gen_core_properties_full_xlsx.py",
    "arg_template": "--field {field.id} --value \"{field.value}\" --out fixtures/xlsx/core-properties-full--{field.id}.xlsx"
  },
  "_expansion": {
    "parent_id": "xlsx/core-properties-full",
    "bindings": {
      "field": "category"
    }
  },
  "assertions": [
    {
      "id": "core-category-present",
      "part": "docProps/core.xml",
      "namespaces": {
        "cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
        "dc": "http://purl.org/dc/elements/1.1/",
        "dcterms": "http://purl.org/dc/terms/"
      },
      "xpath": "//cp:category",
      "must": "exist",
      "description": "The category element must be present in docProps/core.xml."
    },
    {
      "id": "core-category-value",
      "part": "docProps/core.xml",
      "namespaces": {
        "cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
        "dc": "http://purl.org/dc/elements/1.1/",
        "dcterms": "http://purl.org/dc/terms/"
      },
      "xpath": "//cp:category",
      "must": "equal",
      "value": "Reports",
      "description": "The category element's text must equal the supplied value."
    }
  ]
}

Fixture

Download core-properties-full--category.xlsx (4.7 KB)

Reference preview

No rendered reference is available for this case.

Spec notes

ECMA-376 Part 2 / ISO 29500-2 section 11 defines the OPC 'core-properties' part. It carries a mix of Dublin Core, dcterms, and MS-OPC-core elements. This manifest isolates each one in turn so each XPath assertion proves that particular field round-trips. dcterms:created / dcterms:modified are set to a fixed ISO-8601 UTC timestamp in the generator so the fixtures are byte-reproducible.