Intro to PresentationML part 1 - Core architecture and the "presentation" part

I've really dropped the ball here over the past several months. I'd been meaning to post some example PresentationML files and give everyone a walkthrough of the format, but I keep falling behind. Sorry folks.

Today, I'd like to give you a basic overview of the PresentationML format. I'll try to keep it fairly high level today, and then hopefully get into more details in future posts. Let's first start with the basic architecture behind PresentationML. Presentations are naturally componentized:

  • Presentations contain Slides
  • Slides contain Shapes
  • Shapes contain Content

In addition to all the design goals that we had behind the Open XML formats, PresentationML was additionally optimized around slide re-use scenarios. It's common practice for folks to reuse slides from multiple presentations when they are creating a presentation of their own. We call this the "slide library" scenario, and we wanted to make sure that PresentationML was designed to accommodate for this. Because of that, it's pretty easy to grab a single slide, and also quickly get at all the other resources that slide uses, so you can pull it out of the larger presentation without losing information.

If you are not already familiar with the open packaging conventions that we use to structure all Open XML files, you should read up a bit. In PresentationML, the file is broken into a collection of parts, that make for a very robust and versatile format. Here is a diagram of the basic parts that make up a PresentationML file, and how they are related to each other (the "Presentation" part in the middle is the start part):

 

"Presentation" part (the root node)

The primary start part or root node of a presentation is usually called "presentation.xml", although if you are familiar with the open packaging conventions, you know that the part name is not significant, and instead it's the relationships and content types that really determine how the file is interpreted.

The presentation part contains information about the presentation itself. It contains the following structural information:

  • Slide lists ( e.g., slides, masters, IDs, custom shows, etc. ) - While the contents for the various slides are stored in seperate parts, the actual ordering information for the slides is stored in the presentation part.
  • Slide sizes (note that this applies to all slides)

In addition to the structural information, the presentation part also contains the following properties:

  • Text Properties ( e.g., embedded font list, Kinsoku settings, etc. )
  • Save Properties ( e.g., flags for embedding fonts, compressing pictures, etc. )
  • Editor Properties ( e.g., flags for using Right-to-Left mode, etc. )
  • Content Properties ( e.g., first slide number for footers, etc. )

Example of editing the "presentation" part

Here's a quick example of how you can modify the "presentation" part to change the order of your slides. Grab the following basic PresentationML file (*note* this file will work with Beta 1 technical refresh, and should also work with Beta 2 when that comes out):  https://jonesxml.com/labs/presentationML1/SlideReorder.pptx

(If you don't have a copy of the beta, here is an equivalent file in the old binary format so you can see what it would look like when opened: https://jonesxml.com/labs/presentationML1/SlideReorder.ppt)

Let's crack the SlideReorder.pptx file open and take a look at what's inside:

  1. You can use any number of methods to get to the start part, but for simplicities sake, let's just add a ".zip" to the end of the file name and open it using a ZIP tool (I'm just using the Windows shell).
  2. Navigate to the "ppt/presentation.xml" part, which is the start part (the way you tell the start part of course is by opening the "_rels/.rels" part and from there you'll see a pointer to the presentation part).
  3. If you are using a ZIP tool that let's you directly edit the files within, open the "presentation.xml" part in an XML editor or text editor (if you can't edit it directly, just copy it out, and then make the edits). I prefer using an XML editor that let's you "pretty print" the files, otherwise they are a bit difficult to read through (see this post for more info on that).

Here is what the XML for "presentation.xml" looks like:

<p:presentation xmlns:r="https://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="https://schemas.openxmlformats.org/presentationml/2006/3/main">
<p:sldMasterIdLst>
<p:sldMasterId r:id="rId1"/>
</p:sldMasterIdLst>
<p:notesMasterIdLst>
<p:notesMasterId r:id="rId5"/>
</p:notesMasterIdLst>
<p:handoutMasterIdLst>
<p:handoutMasterId r:id="rId6"/>
</p:handoutMasterIdLst>
<p:sldIdLst>
<p:sldId id="256" r:id="rId2"/>
<p:sldId id="257" r:id="rId3"/>
<p:sldId id="258" r:id="rId4"/>
</p:sldIdLst>
<p:sldSz cx="9144000" cy="6858000" type="screen"/>
<p:notesSz cx="6858000" cy="9144000"/>
</p:presentation>

And the relationship file for the presentation.xml part looks like this:

<Relationships xmlns="https://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId8" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" Target="viewProps.xml"/>
<Relationship Id="rId3" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide2.xml"/>
<Relationship Id="rId7" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" Target="presProps.xml"/>
<Relationship Id="rId2" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide1.xml"/>
<Relationship Id="rId1" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" Target="slideMasters/slideMaster1.xml"/>
<Relationship Id="rId6" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster" Target="handoutMasters/handoutMaster1.xml"/>
<Relationship Id="rId5" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="notesMasters/notesMaster1.xml"/>
<Relationship Id="rId10" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" Target="tableStyles.xml"/>
<Relationship Id="rId4" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide3.xml"/>
<Relationship Id="rId9" Type="https://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/>
</Relationships>

Now, if you want to reorder the slides, you can either modify the relationship file, or modify the presentation.xml file. Let's leave the rels file alone, and instead just change the order in the presentation.xml file. Modify it so that it now looks like this:

<p:presentation xmlns:r="https://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="https://schemas.openxmlformats.org/presentationml/2006/3/main">
<p:sldMasterIdLst>
<p:sldMasterId r:id="rId1"/>
</p:sldMasterIdLst>
<p:notesMasterIdLst>
<p:notesMasterId r:id="rId5"/>
</p:notesMasterIdLst>
<p:handoutMasterIdLst>
<p:handoutMasterId r:id="rId6"/>
</p:handoutMasterIdLst>
<p:sldIdLst>
        <p:sldId id="258" r:id="rId4"/>
<p:sldId id="257" r:id="rId3"/>
<p:sldId id="256" r:id="rId2"/>

    </p:sldIdLst>
<p:sldSz cx="9144000" cy="6858000" type="screen"/>
<p:notesSz cx="6858000" cy="9144000"/>
</p:presentation>

Now, if you open the .pptx file, you should see that we've simply reversed the order of the slides. It's a very basic example, but I think it serves as a pretty good first look at the structure of PresentationML.

Go ahead and play around with that a bit, and let me know if you have any questions. The next concept I'll cover is the slide content.

-Brian