Understanding the Open Packaging Convention in Office

The Open Packaging Convention (OPC) is a container-file technology used by modern Microsoft Office formats—such as DOCX, XLSX, and PPTX—to organize, store, and link document data using standard ZIP compression and XML. This article explains the fundamentals of the OPC standard, breaks down its core architectural components, and details how XML relationship files (.rels) manage internal and external resources to construct fully functional Office documents.

What Is the Open Packaging Convention?

The Open Packaging Convention is an open standard defined under ECMA-376 and ISO/IEC 29500. Rather than storing a document as a single, opaque binary stream (such as the legacy .doc or .xls formats), OPC stores a document as a collection of individual modular files—referred to as Parts—bundled inside a standard ZIP archive.

When you rename a .docx, .xlsx, or .pptx file extension to .zip and extract its contents, you expose the underlying OPC architecture, which consists of XML data files, embedded media, metadata, and relationship mappings.

Core Elements of an OPC Package

An OPC package relies on three primary components to function:

  1. Parts: The individual data streams contained within the ZIP archive. These include core content (e.g., word/document.xml), formatting definitions (e.g., styles.xml), embedded assets (such as PNG or JPEG images), and document metadata.
  2. Content Types: Defined in the root file [Content_Types].xml, this component acts as a central registry mapping each part’s file extension or URI to an explicit MIME-style content type. This informs the consuming application how to parse each component.
  3. Relationships: Defined in dedicated .rels files, relationships establish explicit connections between different parts or between a part and an external resource.

How XML Relationship Files (.rels) Work

In the OPC specification, parts do not directly reference the physical file paths of other parts inside their own markup. Instead, content parts reference an abstract Relationship ID (e.g., rId1, rId2). The actual destination path is resolved using an XML relationship file.

Relationship files are always stored in a dedicated subfolder named _rels and bear the extension .rels appended to the target file’s name.

1. Package-Level Relationships

Located at /_rels/.rels, the package-level relationship file defines the primary entry points of the document package. It tells the host application where to find critical package-wide data, such as:

2. Part-Level Relationships

Part-level relationship files define dependencies specific to a particular component. For example, the relationships for word/document.xml are stored in word/_rels/document.xml.rels.

These files define the connections between the main body text and:

Structure of a Relationship Definition

A relationship entry within an XML file follows a standardized schema:

<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship 
        Id="rId1" 
        Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" 
        Target="media/image1.png" />
    <Relationship 
        Id="rId2" 
        Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" 
        Target="https://www.example.com" 
        TargetMode="External" />
</Relationships>

Key attributes include:

Advantages of the OPC Relationship Model