Open Packaging Conventions


The Open Packaging Conventions is a container-file technology initially created by Microsoft to store a combination of XML and non-XML files that together form a single entity such as an Open XML Paper Specification document. OPC-based file formats combine the advantages of leaving the independent file entities embedded in the document intact and resulting in much smaller files compared to normal use of XML.

Specifications

The OPC is specified in Part 2 of the Office Open XML standards ISO/IEC 29500:2008 and ECMA-376.
The ISO/IEC 29500-2:2008 specification and the second edition of ECMA-376 makes a normative reference to PKWARE, Inc.'s .ZIP File Format Specification version 6.2.0, and supplements it with a normative set of clarifications. Note: The older first edition of ECMA-376 makes an informative reference to the newer PKWARE Inc's ".ZIP File Format Specification" version 6.2.1. The ZIP format is not specified by any international standard but has widespread community and developer acceptance.
Microsoft submitted a draft in 2006 to the Internet Engineering Task Force for a "pack" URI Scheme to be used for URI references to OPC-based packages. The draft expired in 2009, the specified syntax is incompatible with the Internet Standard for URI schemes. The scheme is now listed as historical.
The ISO 19165:1-2018 recommends the use of the Open Packaging Conventions to implement the Geospatial Package defined in the Open Archival Information System.

Usage

Both the XML Paper Specification and Office Open XML use Open Packaging Conventions, which provide a profile of the common ZIP format. In addition to data and document content in XML markup, files in the ZIP package can include other text and binary files in formats such as PNG, BMP, AVI, PDF, RTF, or even an already packaged ODF file. OPC also defines some naming conventions and an indirection method to allow position independence of binary and XML files in the ZIP archive.
OPC files can be opened using common ZIP utilities. OPC allow indirection, [|chunking] and [|relative indirection].

File formats using the OPC

The OPC is the foundation technology for many new file formats:
File formatFilename extensionContentStandard
3MF Consortium 3D Manufacturing Format file format.3mfCAD design data for additive manufacturing
Autodesk AutoCAD Design Web Format file format.dwfxCAD design data
Circuit Diagram Document.cddxCircuit diagram containing layout, connections and embedded components
Family.Show file format.familyxgenealogical family data, stories, and photos
Field Device Integration FDI Packages.fdixField Device Integration informationIEC 62769-4:2015
Microsoft Application Virtualization file format.appvPortable application
Microsoft Semblio file format.semblioInteractive learning material, such as e-books containing images, audio, and video
Microsoft Visual Studio 2010+ Extensions file format.vsixIntegrated development environment extension
Microsoft Visio 2013 drawing file format.vsdxReplaces.vsd and.vdx formats used in earlier versions
Microsoft Windows 8, Windows 8.1 and Windows Phone 8.1 App Package.appxSoftware package for applications listed on Microsoft's Windows Store and Windows Phone Store
Microsoft Windows 8.1 and Windows Phone 8.1 App Bundle.appxbundleSoftware package that bundles hardware platforms, languages, and resources for an application listed on Microsoft's Windows Store and Windows Phone Store
Microsoft Windows Azure C# Package.cspkgCloud platform data
Microsoft XML Paper Specification.xpsFixed document for document exchange
MiraMon open compressed map.mmzxGeographic information ISO 19165-1:2018
NuGet Package.nupkgSoftware package for a package management system
Office Open XML Document.docxWord processing documentECMA-376, ISO/IEC 29500:2008
Office Open XML Presentation.pptxPresentation fileECMA-376, ISO/IEC 29500:2008
Office Open XML Workbook.xlsxSpreadsheet workbookECMA-376, ISO/IEC 29500:2008
Open XML Paper Specification.oxpsFixed document for document exchangeECMA-388
Siemens PLM Software file format.jtx
MathWorks Simulink model file.slxDynamic system specification for Model-based design
SMPTE Media Package.smpkStorage format for distribution and playback of multimedia video and audio files
SpaceClaim 3D solid model file.scdocEmbedded 3D CAD data files include Standard ACIS Binary solid model files
Microsoft XAML PackageNot a specification. Function supported by.NET Framework only for saving WPF FlowDocument with images

Programming

OPC is natively supported in Microsoft.NET Framework 3.0 by the System.IO.Packaging namespace. Open source libraries exist for other languages.
Since Windows 7, OPC is also natively supported in the Windows API through a set of COM interfaces, collectively referred to as .
Alternatively, ZIP libraries can be used to create and open OPC files, as long as the correct files are included in the ZIP and the conventions followed.

Package, parts, and relationships

In OPC terminology, the term package corresponds to a ZIP archive and the term part corresponds to a file stored within the ZIP. Every part in a package has a unique URI-compliant part name along with a specified content-type expressed in the form of a MIME media type. A part's content-type explicitly defines the type of data stored in the part and reduces duplication and ambiguity issues inherent with file extensions.
OPC packages can also include relationships that define associations between the package, parts, and external resources. In addition to a hierarchy of directories and parts, OPC packages commonly use relationships to access content through a directed graph of relationship associations. Relationships are composed of four elements:
OPC packages can store parts that contain any type of data. The extension ".rels", however, is reserved for storing relationships metadata within "/_rels" subfolders. The subfolder name "_rels", the file extension ".rels" within such directory, and the filename ".xml" in any folder are the only three reserved names for files stored in an OPC package.


All relationships are represented as XML files. If you open a ".rels" file in a text editor, you can view the actual XML markup that defines all the relationships targeted from that part. A typical relationships file contains XML code like this:






which defines two relations for the root package, the first one being considered as the root package, and the other one being used to reference an alternate form.
The main parts of the embedded documents are often stored within a folder named "/Document", and the optional metadata parts that are not needed for processing the main parts of the document are stored in a folder named "/Metadata"; however these actual folder names are actually specified within the XML-formatted data in ".rels" relationship files and the OPC specification allows any folder organisation that is convenient for the application and these two folder names are not required.

Chunking

It encourages documents to be split into small chunks. This is better for reducing the effect of file corruption. And better for data access: for example, all the style information in one XML part, each separate worksheet or table in their own different parts. This allows faster access and less object creation for clients and makes it easier for multiple processes to be working on the same document.

Relative indirection

In the Open Packaging Conventions, each file that has reference has its own _rels file with the indirection lists. This makes it easier to cut and paste some information with all its associated resources in some cases, provides name scoping to remove the chance of name clashing between files, and so on.