Adventures in Packaging – Episode 1

If you're developer who creates or accesses data files (and who doesn't?), then this blog might be one for you to keep an eye on.

Welcome to the first installment of Microsoft Packaging Team blog!

The Packaging team works in the Microsoft Windows Division to provide programming APIs that support the Open Packaging Conventions standard.  Open Packaging Conventions ("OPC") is a new file technology documented by the ISO/IEC 29500-2 and ECMA 376-2 standards.

Several members of the team worked on the original System.IO.Packaging APIs released for managed-code in .NET 3.0.  We're particularly excited now with the upcoming release of Windows 7 which will include new native-code Win32 Packaging APIs that will ship as part of the operating system!  Microsoft is strongly embracing open standards and interoperability - the commitment to incorporate OPC as an integral element of the operating system is another step in that direction.

Open Packacing ConventionsPerhaps an initial question might be, "what is OPC and what makes it so compelling"?  Rather than being a specific file format, OPC is a container-file technology that's designed to create file formats based on a flexible open framework.  OPC integrates elements of Zip, XML, and the Web into an open industry standard that makes it easier to organize, store, and transport application data.  OPC is the core file technology for many of the new file formats supported by Microsoft products.  This new generation of OPC-based files include Office 12 versions of Word (.docx), Excel (.xlsx), and PowerPoint (.pptx), along with XPS (.xps), Semblio (.semblio), plus a growing number of other new Microsoft and third-party applications such as Autodesk AutoCAD (.dwfx) and Siemens UGS (.jtx).  While each of these file formats share OPC as a foundation, the data content contained in each differs depending on the specific format.  Before going too much further, perhaps a couple of words on terminology.

In packaging terms...

    • A "package" corresponds to a "Zip archive".
    • A "part" corresponds to a "file" (i.e. "a data stream") stored within the Zip.

In using Zip as its physical container, all OPC-based file formats are, in fact, Zip files.  You can simply append ".zip" to any OPC file (package) to open and examine its contents in Windows Explorer or your favorite Zip utility. This makes packages a great choice for organizing multiple application data streams into a single file that’s portable and easy to access.  It’s important to note, however, that while all OPC files are Zip files, the reverse is not necessarily true: not all Zip files are OPC files.  OPC adds two requirements to a Zip file:

    1. The names of all of the parts (files) stored in an OPC package must be URI-compliant.
    2. The package must contain a “[Content_Types].xml” file.

URI Part Names
The first requirement*, URI-compliant part names, enables potential web-access to the parts stored in a package when the package is located on a web server.  In situations where an original filename is not URI-compliant, the filename is typically "percent-encoded" to a URI-compliant form.  For example, a part with the filename "my file.txt" would be percent-encoded as "my%20file.txt" (you've probably seen this in many of the URLs on your Web browser).
*Re. ISO 29500-2, Section 9.1.1 “Part Names”.

The [Content_Types].xml Part
The second requirement**, a "[Content_Types].xml" part, is used so that the content of all the parts in the package are clearly and accurately defined, not only today but into the future.  Since many three or four characters filename extensions have multiple meanings, Content_Types is used to accurately define part content through the use of MIME-style media types.  The markup within a Content_Types part is fairly simple and contains just two basic types of elements: "Default" and "Override" elements.

    • Default: associates a generic file "Extension" to a specified "ContentType".
    • Override: associates a specific "PartName" to a specified "ContentType"
      (overrides any Default extension association).

The following is an example of a [Content_Types].xml part:

<?xml version="1.0" encoding="utf-8" ?>
<Types xmlns="">
  <Default Extension="htm" ContentType="text/html" />
  <Default Extension="css" ContentType="text/css" />
  <Default Extension="png" ContentType="image/png" />
  <Default Extension="jpg" ContentType="image/jpeg" />
  <Default Extension="mp3" ContentType="audio/mpeg3" />
  <Default Extension="xml" ContentType="application/xml" />
  <Override PartName="/docProps/core.xml"
   ContentType="application/vnd.openxmlformats-package.core-properties+xml" />

When using the Win32 native-code Packaging APIs or .NET managed-code Packaging APIs the Content_Types file is created and managed automatically.  If you're creating a Zip package on your own you'll also need to include a [Content_Types].xml file that contains the markup to define the content types for all of the parts contained in the package. As shown in the above example this is fairly simple to do.
**Re. ISO 29500-2, Section 9.1.2 “Content Types”.

The Adventure Continues...
These are some basics to help get you started but there are many other additional services that OPC provides.  A goal of this blog will be to highlight uses and features of both the Win32 native-code Packaging and .NET managed-code System.IO.Packaging APIs for creating, organizing, and accessing information stored in OPC files.  We think you'll find the Open Packaging Conventions an exceptionally flexible standard for managing application data; and in particular, the packaging APIs an indispensable tool to help you take advantage of this new file technology - more to come in following episodes...

Thanks for listening,

PS: Here are some links for more information and related topics about Packaging:

Comments (9)

  1. says:

    The url for OPC APIs: Win32 Native-Code – Packaging under the Resource sections, points to OPC APIs: .NET Managed-Code – System.IO.Packaging.

    Can you please correct this?

  2. Jack-Davis says:

    Hi smshekar,

    I fixed the "Resource" link for ‘OPC APIs: Win32 Native-Code" – it now points to

    Thanks for spotting this!

  3. JC Cimetiere says:

    Hey great opening.

    By the way, here are a couple of non-Microsoft technologies using OPC in the context of Open XML. Apache POI Java API and PHP Excel. Intro & demo here:


  4. Open XML Developer There are some great new articles: Introduction to the Open XML SDK 2.0 XSLT transforming

  5. Encore cette fin de semaine, voici les quelques posts ou astuces que j’ai pu rencontrer sur la toile

  6. Garry Trinder says:

    For the relevant people at MS:

    Has their been any thought of utilizing OPC as an application deployment package that would help MS achieve their goals of separating app and OS state? For existing installation packages (.msi, et al.), files written during installation could be redirected into a dynamically created OPC, possibly including the original installer within that package.

    For shared components, there would still be a need to somehow register these, but the registry could point to files within an OPC app package rather than a loose file on disk, and possibly either copy that file into the other applications’ packages or into a commonly accessible OPC package that any app may reference.

    I’m almost certain this would just be an extension of the manifest-backed packages and work currently ongoing with App-V, but the thought crossed my mind, and I thought it would be a potentially cool scenario providing greater accessibility to and migration of application state.

  7. Jack-Davis says:

    Hi n4cer,

    Regarding your question, "Has their been any thought of utilizing OPC as an application deployment package that would help MS achieve their goals of separating app and OS state?"

    Check out the new ".appx" application packaging technology coming out for new Metro style apps in Windows 8!   See…/hh464929(v=VS.85).aspx

    Also Wikipedia lists a growing number of new OPC-based file formats – see…/Open_Packaging_Conventions

  8. Packaging says:

    Great blog and very interesting. It's also very informative. Thanks for sharing.

    Please visit my website:

Skip to main content