A package’s metadata is in the parts docProps/core.xml,
docProps/app.xml and, when there are any, docProps/custom.xml,
reached by the relationships of the package itself in _rels/.rels. These
parts are not needed to read the document, and they commonly hold authors’ names.
Core properties: core.xml
<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:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:title>Annual report</dc:title>
<dc:creator>Ada Example</dc:creator>
<cp:lastModifiedBy>Ben Example</cp:lastModifiedBy>
<cp:revision>3</cp:revision>
<dcterms:created xsi:type="dcterms:W3CDTF">2024-05-17T13:45:00Z</dcterms:created>
<dcterms:modified xsi:type="dcterms:W3CDTF">2024-05-18T09:00:00Z</dcterms:modified>
</cp:coreProperties>
| Element | Meaning |
|---|---|
dc:title, dc:subject, dc:description | Title, subject and description (“comments”). |
dc:creator | The author. |
cp:keywords, cp:category, cp:contentStatus | Keywords, category and status. |
cp:lastModifiedBy | Who saved it last. |
cp:revision | The revision number of the content, a string (Part 2 8.3.4.4.7, example 4). Word counts saves in it, but the standard does not say so. |
dcterms:created, dcterms:modified | Dates, in W3CDTF. |
cp:lastPrinted | When it was last printed. |
dc:language, dc:identifier, cp:version | Language, an identifier and a version string. |
Application properties: app.xml
The root is Properties in the
…/officeDocument/2006/extended-properties namespace.
| Element | Meaning |
|---|---|
Application, AppVersion | The program that saved it, such as Microsoft Office Word and 16.0000. AppVersion shall have the form XX.YYYY (digits), or the document is not conformant (22.2.2.2); it only tells versions of one producer apart. |
Template | The name of the external template the document was made from (22.2.2.25). |
TotalTime | Total editing time; the default unit is minutes (22.2.2.27). |
Pages, Words, Characters, CharactersWithSpaces, Lines, Paragraphs | Counts as the producer worked them out when it last saved (22.2.2.18, .28, .3, .4, .13, .19), all xsd:int. |
Company, Manager | A company and a supervisor associated with the document (22.2.2.5, .15). |
DocSecurity | An int that is a set of flags (22.2.2.7): 1 password protected, 2 recommended read-only, 4 enforced read-only, 8 locked for annotation. |
HyperlinksChanged | Boolean: hyperlinks were changed only in this part, and the next producer to open the document shall update the hyperlink relationships from it (22.2.2.12). |
LinksUpToDate | Boolean: true if the hyperlinks are up to date (22.2.2.14). |
ScaleCrop | Boolean: true scales the thumbnail to the display, false crops it to what fits (22.2.2.22). |
SharedDoc | Boolean: the document is currently shared between producers, who should take care when updating it (22.2.2.23). |
HyperlinkBase | The base string for relative hyperlinks (22.2.2.11). |
HLinks | The hyperlinks the document had when last saved, a vt:vector of variants (22.2.2.10). |
HeadingPairs, TitlesOfParts | Conceptual groups of the document and their names, not parts of the package (22.2.2.8, .26). HeadingPairs is a vt:vector of variant alternating a group title (lpstr) and the number of titles in it (i4); TitlesOfParts is a vt:vector of lpstr with all the titles, group after group. |
DigSig | A vt:blob holding the signature of a digitally signed legacy binary document. Legacy only; the standard says to prefer the signatures of Part 2 chapter 10 (22.2.2.6). |
Slides, Notes, HiddenSlides, MMClips, PresentationFormat | Presentation counts (slides, slides with notes, hidden slides, sound or video clips) and the intended format; they belong to PowerPoint files and have no meaning in a Word document (22.2.2.24, .17, .9, .16, .20). |
Nothing checks these values: another program may have saved the file and written different numbers, or left the part out.
Custom properties: custom.xml
<Properties
xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="Project">
<vt:lpwstr>Example</vt:lpwstr>
</property>
</Properties>
The thumbnail
A package may have a thumbnail relationship to an image part, usually
docProps/thumbnail.jpeg, showing the first page. Word saves one when the option
to save a preview picture is on. It stays as it was when last saved, so it can show text
that has since been changed. Part 2 chapter 9 says only that a thumbnail part is an image part
reached by a part or package relationship of the thumbnail type (listed in Annex E).
Properties in detail
Sources read: ECMA-376 Part 2 8.2 to 8.3.4.4.8 and 9; Part 1 15.2.12 to 15.2.12.3 and 22.2 to 22.4
(the Part 1 text read is the Strict wording, with purl.oclc.org names); the schemas
opc-coreProperties.xsd, shared-documentPropertiesExtended.xsd and
shared-documentPropertiesCustom.xsd; MS-OI29500 2.1.30, 2.1.31 and 3.11.
The three parts and how they are reached
- A package has at most one of each part, and each is the target of a relationship in the package’s own relationships part (Part 2 8.2; Part 1 15.2.12.2, 15.2.12.3). The core part has the content type
application/vnd.openxmlformats-package.core-properties+xml(Part 2 Annex E), the extended partapplication/vnd.openxmlformats-officedocument.extended-properties+xml, the custom partapplication/vnd.openxmlformats-officedocument.custom-properties+xml. The custom part (15.2.12.2) shall be internal (TargetModeInternal) and shall have no relationships to other parts; the extended part (15.2.12.3) has the same rules (at most one, target of a package relationship, internal, no relationships to other parts; read in the standard's text), with root elementPropertiestoo. Both shall be the target of a relationship in the package-relationship item. - Relationship types: Part 1 15.2.12.1 sends the core part to Part 2. The Strict text of 15.2.12.2 and 15.2.12.3 gives the source relationships as
http://purl.oclc.org/ooxml/officeDocument/relationships/customPropertiesand…/extendedProperties(root namespaceshttp://purl.oclc.org/ooxml/officeDocument/customPropertiesand…/extendedProperties); the examples abbreviate them as…/custom-propertiesand…/extended-properties, the Transitional names. For the core part the standard’s source relationship is…/officedocument/2006/relationships/metadata/core-properties, but Office useshttp://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties(MS-OI29500 2.1.30). - All three parts are optional; if every extended or custom element is omitted the part can be left out (Part 1 22.2, 22.3).
Rules for core.xml
- The root is
coreProperties, with no attributes, and the part shall be valid againstopc-coreProperties.xsd(Part 2 8.3.1, 8.3.3). The schema is anxs:all: the 15 elements may come in any order, each at most once (8.3.4.1: core property elements are non-repeatable and can be empty or omitted). - From Dublin Core (ISO 15836-1, namespace
http://purl.org/dc/elements/1.1/) are allowedcreator,description,identifier,language,subjectandtitle. They shall have no child elements and noxsi:typeorxml:langattribute (8.3.4.2). createdandmodified(ISO 15836-2, namespacehttp://purl.org/dc/terms/) shall have no child elements and noxml:lang, and shall carryxsi:type="dcterms:W3CDTF"withdctermsdeclared as the prefix of that namespace (8.3.4.3).- Defined by Part 2 itself, with no attributes:
category(string, such as “Resume” or “Proposal”),contentStatus(string, such as “Draft”, “Reviewed”, “Final”),lastModifiedBy(string: a name, e-mail address or employee ID),lastPrinted(xsd:dateTime, so2017-01-01alone is the example in the standard though a bare date is not a validxsd:dateTime; the other example is2017-04-17T14:20:10+09:00),revision(string) andversion(string) (8.3.4.4.1 to 8.3.4.4.8). keywordshas mixed content: text of its own plusvaluechildren, and an optionalxml:langon both. In<keywords xml:lang="en-US">color<value xml:lang="en-CA">colour</value><value xml:lang="fr-FR">couleur</value></keywords>each keyword can be tagged with its own language (8.3.4.4.3, 8.3.4.4.4).- The part shall not contain elements or attributes of the Markup Compatibility namespace (8.3.2). New kinds of property are added by a new part with a new relationship type, never inside this part.
Rules for app.xml
- The root is
Properties; the content type and relationship are in the list above. The 28 elements ofCT_Propertiesare in anxsd:allgroup: any order, each at most once, any of them empty or absent (Part 1 22.2;shared-documentPropertiesExtended.xsd). The schema’s order isTemplate,Manager,Company,Pages,Words,Characters,PresentationFormat,Lines,Paragraphs,Slides,Notes,TotalTime,HiddenSlides,MMClips,ScaleCrop,HeadingPairs,TitlesOfParts,LinksUpToDate,CharactersWithSpaces,SharedDoc,HyperlinkBase,HLinks,HyperlinksChanged,DigSig,Application,AppVersion,DocSecurity. - For string properties, characters that XML 1.0 cannot hold are written as
_xHHHH_(22.2.2.21).
Rules for custom.xml and the variant types
- The root
Propertiesholds any number ofpropertyelements. Each has exactly one child, which is a variant type (22.3.2.2; the schema’s choice has 33 of them:vector,array,blob,oblob,empty,null,i1,i2,i4,i8,int,ui1,ui2,ui4,ui8,uint,r4,r8,decimal,lpstr,lpwstr,bstr,date,filetime,bool,cy,error,stream,ostream,storage,ostorage,vstream,clsid). - Attributes:
fmtid(required, a GUID in the form{HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH}) andpid(required, anint) together tie the property to an OLE property;name(optional string) identifies it;linkTarget(optional string) names a bookmark (WordprocessingML) or a table or named cell (SpreadsheetML) the value is taken from. WhenlinkTargetis present the value is a cache and is replaced from the bookmark on save; if the bookmark is missing the link is broken and the cached value is kept (22.3.2.2). - The standard defines no property names or values (MS-OI29500 2.1.31). Office reserves a number of names (MS-OI29500 3.11): the ones of the older binary formats listed in [MS-OSHARED] 2.3.3.2.3.2 (that document was not read here, so those names are not listed), and, when a sensitivity label is applied,
Sensitivity(the GUID of the label) and for WordClassificationContentMarkingHeaderText,…HeaderFontProps(#RRGGBB,size,font),…HeaderShapeIds(hexadecimal shape IDs, continued in…ShapeIds-1,-2… when too long), the same forFooter, andClassificationWatermarkText,…FontProps,…ShapeIds. PowerPoint writes header and footer text and…Locations(design name, a colon, the shape ID; several separated by a backslash, with colon and backslash in a name escaped by a backslash). A reserved name shall only carry the data it is reserved for. The meaning of any other name is whatever the user or program that wrote it decided; a reader shows the raw value. - Variant element content (Part 1 22.4.2):
boolisxsd:boolean;i1toi8,ui1toui8,int,uintare integers of those sizes;r4andr8arefloatanddouble;decimalisxsd:decimal;dateandfiletimearedateTime(RFC 3339);cyis a currency with exactly four decimals, matching\s*[0-9]*\.[0-9]{4}\s*;erroris a 32-bit status of the form0xHHHHHHHH;clsidis a GUID;lpstr,lpwstrandbstrare strings with_xHHHH_escapes, and a literal_xHHHH_is written_x005F_xHHHH_(22.4.2.4);blob,oblob,stream,ostream,storage,ostoragearebase64Binary(blobbeing a DWORD byte count then the bytes);vstreamis a stream with a GUIDversion;emptyandnullhave no content;variantholds exactly one child of any variant type and is valid only insidevectororarray. vector(attributesbaseType, one of variant, i1, i2, i4, i8, ui1, ui2, ui4, ui8, r4, r8, lpstr, lpwstr, bstr, date, filetime, bool, cy, error, clsid, andsize, the number of items) holds items all of that one type.array(baseTypeone of variant, i1, i2, i4, int, ui1, ui2, ui4, uint, r4, r8, decimal, bstr, date, bool, cy, error;lBoundsanduBounds, comma-separated integers, one per dimension) fills its items with the first index running fastest; positions not given are null, with no default (22.4.2.1, 22.4.2.33).
Divergence from spec
- Core relationship type. The standard names a relationship type under
officedocument/2006/relationships/metadata/core-properties; Office writes and usespackage/2006/relationships/metadata/core-properties(MS-OI29500 2.1.30). A reader that wants real files must accept the package form. - python-docx (
docx/oxml/coreprops.pyanddocx/opc/coreprops.py, read): the property calledcommentsisdc:descriptionandauthorisdc:creator;revisionreads as 0 when absent, not an integer or negative, and the setter accepts only integers of 1 or more; strings are limited to 255 characters on write; dates are parsed from the W3CDTF formsyyyy,yyyy-mm,yyyy-mm-ddandyyyy-mm-ddThh:mm:sswith an optional numeric offset (applied, and the result marked UTC) and an invalid date reads as none; dates are written as%Y-%m-%dT%H:%M:%SZwithxsi:type="dcterms:W3CDTF"oncreatedandmodified. It does not readapp.xmlorcustom.xml. - Apache POI (
POIXMLProperties.java, read): core, extended (template, manager, company, presentation format, application, version, pages, words, characters, characters with spaces, lines, paragraphs, slides, notes, total time, hidden slides, MM clips, hyperlink base) and custom properties. A new custom property getsfmtid{D5CDD505-2E9C-101B-9397-08002B2CF9AE}and the nextpidafter the highest in use, starting at 2; it writes onlylpwstr,r8,i4andboolvalues; adding a name that exists throws. POI offers no accessor forHeadingPairs,TitlesOfParts,HLinksorDigSigbeyond the underlying XMLBeans object. - Word writes
fmtid{D5CDD505-2E9C-101B-9397-08002B2CF9AE}and ids from 2 on (the standard’s own examples do the same); nothing in the standard requires that value. - The standard’s own example for
lastPrinted(8.3.4.4.6) is the bare date2017-01-01, which is not a validxsd:dateTime, the type the schema gives. The viewer shows the text as written. - LibreOffice (
oox/source/docprop/docprophandler.cxx, master, read): the dates are parsed from the W3CDTF formsyyyy,yyyy-mm,yyyy-mm-ddandyyyy-mm-ddThh:mm[:ss[.fraction]], an offset is converted to UTC, and a text shorter than four characters is ignored (96–191, 437–471).keywordsis split on space, comma, semicolon, colon and tab, with runs merged (193–215), so a keyword with a space becomes two.TotalTimeis taken as minutes and stored as seconds (509–525); the statistics (Characters,CharactersWithSpaces,Pages,Words,Paragraphs) become document statistics.category,contentStatus,contentType,identifierandversionare kept as custom properties namedOOXMLCoreProperty…;Company,Manager,AppVersion,HyperlinkBaseandPresentationFormatlikewise. The boolean and count properties (HyperlinksChanged,LinksUpToDate,ScaleCrop,SharedDoc,DocSecurity,Notes,Slides,MMClips,HiddenSlides) are kept only when not the default (536–598).Lines,DigSig,HeadingPairs,HLinksandTitlesOfPartsare ignored on import (625–631). Custom properties of a name that clashes with one of these are silently dropped (88–89). The standard states none of this; it is the behaviour of the key program.
Not compared: docx4j (no source read for properties), [MS-OSHARED] 2.3.3.2.3.2 (the reserved names of the binary formats).
What the viewer shows
The Document table of the overview shows every core property with a value (title, subject, author, keywords with each language-tagged value, description, category, status, language, last modified by, revision, created, modified, last printed, and any other element found in the part), the application, company, manager, template, stated page, word and character counts, characters with spaces, lines, paragraphs, editing time, the DocSecurity value with the meaning of each bit set, and every other extended element by name (HyperlinkBase, ScaleCrop, SharedDoc, LinksUpToDate, HyperlinksChanged, HeadingPairs, TitlesOfParts, HLinks, the presentation counts). Vectors and arrays are shown as their items joined with semicolons. The Custom properties table lists all properties, with no limit, each with its name, variant type, value, fmtid and pid, and linkTarget; _xHHHH_ escapes in names and strings are decoded. Reserved names are shown like any other, with the raw value. The thumbnail is shown with the pictures of the package, and each row links to its part in the tree.