Skip to main content

Wouter

Go Search
Home
Contact Me
  

Wouter > Posts > Package awareness in Package Explorer 3.0
Package awareness in Package Explorer 3.0

One of the last things I needed to fix before I can release Package Explorer 3.0 is the framework for creating new documents and parts. The stuff in the current beta is rather buggy so a redesign was in order. I do like the feature because it allows you to build your demo documents in tiny steps which is great for figuring out how Open XML works.

Earlier I had a template-based model alla Visual Studio. Nice, but there was a lot of work in creating the templates and a template is not useful for anything else but adding new content to a package. Since a redesign was in order anyway I have spent some time thinking through how to best implement this and I think the result is nice for all Open XML developers.

First of all let me explain my idea. Basically I want to have a few features. Better validation of packages is one goal. Package Explorer already supports schema-based validation of the XML content, but missing a Slide Master in a presentation is something that it will not pick up. Now in order to find these errors you need to have a 'packaging vocabulary' to validate against, like an XSD for XML. The nice thing about adding this into the core of Package Explorer is that using this vocabulary we have a more intimate knowledge of what the package type is and we can adjust UI and features accordingly. Package Explorer has been quite unaware of Open XML up until now. It only knows about the packaging structure (hence the name is 'package explorer' ehJ) The second benefit of adding vocabularies into the core is that we can now use our knowledge of the allowed structure of a package to filter the 'Add New Part' dialog to only show the parts that are allowed. Heck, we don't even need a template anymore since the spec often dictates what the root-element of an XML file should be, and we can combine this knowledge with the XSDs to generate templates on the fly. Nice!

So a packaging vocabulary is:

  • Like the XML-Schema files for the XML content but targeted to packaging structures

If you have a packaging vocabulary defined you can:

  • Validate the structure of packages
  • Find out how parts can be joined together (used in the PE 3.0 New Part dialogs)
  • Generate templates for new parts on the fly
  • Perform better validation of XML content since we now know the required root element

Luckily the ISO spec does hold information about packaging structure. It is just not stored in a digitally useful format (XML). So I spent some time this week creating my own XML structure. Here is a small excerpt:

<partType name="DocumentSettings"
  allowExternal="false"
  rootNamespace=http://schemas.openxmlformats.org/wordprocessingml/2006/main
  rootElement
="settings"
  sourceRelationship=http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings>
  <contentType name="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" />
  <reference name="DocumentTemplate" minOccurs="0" maxOccurs="unbounded" type="explicit" />
  <reference name="MailMergeDataSource" minOccurs="0" maxOccurs="unbounded" type="explicit" />
  <reference name="MailMergeHeaderDataSource" minOccurs="0" maxOccurs="unbounded" type="explicit" />
  <reference name="XSLTransformation" minOccurs="0" maxOccurs="unbounded" type="explicit" />
</partType>

See, all the information we need neatly gathered into a format that you can easily query. I currently have WordprocessingML and the Shared stuff ready. Still need to do SpreadsheetML, PresentationML and DrawingML (pffff)

The first place where I choose to surface this information is in the Document Inspector. You can now toggle the "Vocabulary" view and get the following result:

Package Explorer also validates the package structure on opening of a document.

Note that the errors here are due to two things. First of all I didn't have time to implement the DrawingML vocabulary yet. So the Theme part fails. The second error for the Core.XML core properties part is due to the fact that the packaging relationship changed between the ECMA and ISO versions of the spec. Package Explorer currently only allows the ISO vocabulary.

Hope it helps!

Comments

There are no comments yet for this post.
Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Name (required) *


Your Url

Type the Web address: (Click here to test)  

Type the description: 

Comments (required) *

Attachments